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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:52:30+00:00 2026-06-11T18:52:30+00:00

I have a bunch of checkboxes when submitted the values (if checked) are added

  • 0

I have a bunch of checkboxes when submitted the values (if checked) are added to an array and serialized then saved on my db in one row.

Now I’d like to show the checkboxes on an edit page with the appropriate checkboxes checked.

I’m currently outputting the checkboxes as such…

HTML

6 w <input type="checkbox" name="size[]" value="6 w">
7 w <input type="checkbox" name="size[]" value="7 w">
8 w <input type="checkbox" name="size[]" value="8 w">

I’ve tried echoing out a checked value but not sure how to get the right ones checked. This was one suggestion from a site I came across…

HTML

6 w <input type="checkbox" name="size[]" value="6 w" <? echo $checked['6 w'] ?> >
7 w <input type="checkbox" name="size[]" value="7 w" <? echo $checked['7 w'] ?> >
8 w <input type="checkbox" name="size[]" value="8 w" <? echo $checked['8 w'] ?> >

PHP

$size = unserialize($row["size"]);        
$array = "";
foreach($size as $size_available)
{
  $array .= "$size_available,";
}
  $array_explode = explode(',',$array);

    //$checked = "";
    foreach ($array_explode as $v){
    $checked[$v] = "checked='CHECKED'";
}

This almost works showing the correct checkboxes checked but any checkboxes not stored in the array give out an undefined index error. I’m guessing because it is outputting an empty variable???

Any suggestions where to go from here or how to do this a better way?

Cheers

  • 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-11T18:52:32+00:00Added an answer on June 11, 2026 at 6:52 pm

    Validate that the index is set before accessing it with isset() –

    <? echo (isset($checked['8 w']))? $checked['8 w'] : "" ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of checkboxes tha start with CheckRR_ I like to loop
I have a bunch of related checkboxes, with integer values. I'm trying to encompass
I have a bunch of checkboxes, that I'd really like to make the user
I have a bunch of nested checkboxes. I would like to make a selection
I have a bunch of checkboxes like this. If the Check Me checkbox is
I have a bunch of checkboxes, and then this master checkbox that will uncheck,
I'm a little new to javascript. I have a bunch of checkboxes for an
I have a web form with a bunch of checkboxes; when a specific box
I have an application settings page with a bunch of checkboxes. How should I
I have bound a flagged enum to a bunch of checkboxes by using a

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.