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 7629525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:51:26+00:00 2026-05-31T05:51:26+00:00

I was looking in stackoverflow, but i do not find exactly what I need.

  • 0

I was looking in stackoverflow, but i do not find exactly what I need. I need to insert checkboxes data sent with php into mysql like this 22111,22332,12123,121132.

I have this code (found here in the site)

<?php 
foreach($_POST['idecod'] as $check) {
            $sel = $check.',';}

$contenedor = "UPDATE inmdes SET idecod='$sel'";

$insertdb = mysql_query($contenedor) or die(mysql_error());

?>

Of course I have the checkboxes as an array:

<input name="idecod[]" type="checkbox" value="<?php echo $rs[0]; ?>"  />

How can i insert multiple checkboxes like 2211223,2211223,1212233,12332122 or if is just one 222111222..???

And how can i retrive them as an array because i need to use something like this

<? php if (in_array('2211223', $idecod)) echo "checked"; ?>

To automatically check the previous checked boxes.!

Thanks in advance

Roberto

UPDATE

I have a list of options. These options act/des with checkboxes. I need to:

1.- Be able to register options checked (SOLVED thanks to @prodigitalso)
2.- Be able to automatically check the checkboxes previously checked.

So, I have the codes like this 221122,221133,225566,445522 in the table (mysql). I need the script to check what codes where previously checked (those that are in the table) and check them. For example:

I see the 5 options 221122,221133,225566,445522 and 663322. I check only 4 (221122,221133,225566,445522) and this is UPDATED in mysql database.

I come again to the options page. But previously i checked 221122,221133,225566,445522. So the script check EACH checkbox. So automatically check options 221122,221133,225566,445522 BUT it doesnt check 663322.

RS[0] is the code, for example 221122.

  • 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-05-31T05:51:27+00:00Added an answer on May 31, 2026 at 5:51 am

    You should use explode and implode.

    if(isset($_POST['idecod']) && !empty($_POST['idecod'])) {
       $sel = implode(',', $_POST['idecod']);
       $contenedor = sprintf("UPDATE inmdes SET idecod='%s'", mysql_real_escape_string($sel));
       $insertdb = mysql_query($contenedor) or die(mysql_error());
    }
    

    then when you pull them out just use:

    $idecodArr = explode(',', $row['idecod']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried looking on stackoverflow, but can't quite find the same issue as me
Like https://stackoverflow.com/questions/1521646/best-profanity-filter , but for Python — and I’m looking for libraries I can
I have been looking around ocn Google and Stackoverflow but haven't found what I
I'm lately feeling the need to learn a build tool. I'm looking through StackOverflow
I have been looking through the questions asked on StackOverflow, but there are so
This might seem like a silly question, but after asking some questions on stackoverflow
I was looking for a JQuery dropdown bar (like the one in StackOverflow) when
I like the Stack Overflow comment UI a great deal and I'm looking into
I've been looking for an answer to this question but I could find none
The problem appeared to be very simple, but I can not find any solution

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.