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

  • Home
  • SEARCH
  • 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 1053841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:18:53+00:00 2026-05-16T17:18:53+00:00

Following situation: I stored a checkbox array with implode in a mysql table field.

  • 0

Following situation: I stored a checkbox array with implode in a mysql table field. Now, in order to update the checkboxes, I want to read the table field content, explode it into its parts and assign it to the respective checkboxes.

So far I managed to read out and explode the table field content into different chunks, my difficulty is how to assign to the respective checkboxes.

Here is the checkbox field:

<tr>
   <td><input class="field checkbox" type="checkbox" name="appbox[]" value="Automotive" <?php $appbox_checked ?> /><label class="choice">Automotive</label></td>
   <td><input class="field checkbox" type="checkbox" name="appbox[]" value="Backlights" <?php $appbox_checked ?> /><label class="choice">Backlights</label></td>
   <td><input class="field checkbox" type="checkbox" name="appbox[]" value="LED lighting" <?php $appbox_checked ?> /><label class="choice">LED lighting</label></td>
  </tr>
  <tr>
   <td><input class="field checkbox" type="checkbox" name="appbox[]" value="IR" <?php $appbox_checked ?> /><label class="choice">IR</label></td>
   <td><input class="field checkbox" type="checkbox" name="appbox[]" value="Signage/Traffic Lights" <?php $appbox_checked ?> /><label class="choice">Signage/Traffic lights</label></td>
   <td><input class="field checkbox" type="checkbox" name="appbox[]" value="Mobile Devices" <?php $appbox_checked ?> /><label class="choice">Mobile devices</label></td>
  </tr>

and here is the php code:

$storebox = explode(", ", $chunk0);
    for($i = 0; $i < count($storebox); $i++){
    echo "Piece $i = $storebox[$i] <br />";
    }

The chunk content matches the value field of the checkbox. So what I need is basically:

if ‘chunk content’ = ‘checkbox value’
then <?php $appbox_checked ?> will echo ‘checked’

Or maybe there is a simplier solution. Thanks for you help guys!

  • 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-16T17:18:53+00:00Added an answer on May 16, 2026 at 5:18 pm

    Easiest way is to use in_array():

    The place where you’re writing <?php $appbox_checked ?>, replace it with this (example Automotive)

     <?php if(in_array('Automotive', $storebox)) echo 'checked="checked"'; ?>
    

    Similarly, for all lines. e.g. for Backlights, replace it with:

     <?php if(in_array('Backlights', $storebox)) echo 'checked="checked"'; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following situation; I want to send a couple of variables
I've got the following situation: I want to store data, which represents, if a
I'm trying to overcome the following situation. Given a directory stored on an NTFS
I am solving in these days following situation: In my DB table I have
I have the following situation: I have a java code launching a stored procedure.
Imagine following situation: There is a distributed key/value database stored on computer network. One
Say I have the following situation (for demonstration). The simple table content is converted
Did you ever have the following situation: you need to store information, but a
following situation: <body> <div style=position:fixed; width:100%>[place holder for header]</div> <div style=position:relative;width:100%;margin-top:100px>[content]</div> </body> I need
Following situation: I need a container for data with a rowindex. Currently we use

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.