Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7858107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:16:23+00:00 2026-06-02T21:16:23+00:00

I should be able to figure this out, but I keep going in circles.

  • 0

I should be able to figure this out, but I keep going in circles. I have a form with checkboxes. When the checkboxes are selected they tagged to be deleted.

I process those selected checkboxes with a foreach:

foreach (array_keys($_POST['checkboxselect']) as $k) {
    $str .= $k.',';
}

This is my lame attempt to put the list of videos together. The sql delete I’m using is:

DELETE FROM `videos` WHERE `video_name` IN ($str)

So I’m missing lots of things here. The $str needs to have:

  1. Only one checkbox is returned so return string with quotes (i.e. “myvideo.mp4”)
  2. Multiple checkboxes are selected so build a string with quotes and commas (i.e. “myvideo.mp4″,”myvideo2.mp4″,”myvideo3.mp4”)

Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:16:25+00:00Added an answer on June 2, 2026 at 9:16 pm

    Try using PHP’s implode:

    // Init links
    $mysqliLink = mysqli_connect('host', 'user', 'password') or die('Could not connect: ' . mysqli_error());
    
    $mysqlLink = mysql_connect('host', 'user', 'password') or die('Could not connect: ' . mysql_error());
    
    //-----
    // Prep values for query
    //-----
    
    // Only pick one of the following depending upon the mysql library you are using
    
    // If using mysql, passing the 2nd argument is not necessary, but for 
    // clarity, adding it
    $deleteNames = array_map('mysql_real_escape_string', array_keys($_POST['checkboxselect']), array_fill(0, count($_POST['checkboxselect']), $mysqlLink));
    
    // If using mysqli
    // This will ensure that $mysqliLink will be passed in as first arg for 
    // every iteration satisfying the function signature
    $deleteNames = array_map('mysqli_real_escape_string', array_fill(0, count($_POST['checkboxselect']), $mysqliLink), array_keys($_POST['checkboxselect']));
    //-----
    
    
    // Because you are passing strings, we need to ensure each is wrapped in quotes
    $deleteNames = "'" . implode("','", $deleteNames) . "'";
    
    // Construct query using implode
    $sql = sprintf('DELETE FROM `videos` WHERE `video_name` IN (%s)', $deleteNames); 
    

    — Update —

    Using Joomla APIs:

    $db = &JFactory::getDBO();
    
    // Localize and sanitize each individual value
    foreach (array_keys($_POST['checkboxselect']) as $element) {
        $deleteNames[] = $db->quote($element);
    }
    
    // Because you are passing strings, we need to ensure each is wrapped in quotes
    // No longer true because $db->quote taking care of quoting out each name for us
    $deleteNames = implode(',', $deleteNames);
    
    // Construct query using implode
    $sql = sprintf('DELETE FROM `videos` WHERE `video_name` IN (%s)', $deleteNames);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, completely noob question I should be able to figure out but I am
I know I should be able to solve this myself, but I've been banging
Ok, I have this script working 99% of how it should be working, but
I been having trouble trying to figure this out. When I think I have
In my application users should be able to define dates when they are available.
I have a web based system where users should be able to fetch data
The problem itself is simple, but I can't figure out a solution that does
I assume I should be able to do it like so: var date =
It seems like I should be able to perform bit shift in C/C++ by
WPF is great in that I should be able to use {StaticResource MyBackground} instead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.