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

The Archive Base Latest Questions

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

Thanks for taking the time to look at this question. Currently, I have a

  • 0

Thanks for taking the time to look at this question.

Currently, I have a piece of code that creates four checkboxes labeled as “Luxury, Brand, Retailer,” and “B2B.” I have looked into a number of PHP methods to create checkboxes, and I felt the implode() function was the most simple and suitable for my job. I have looked into a number of tutorials to create the implosions, however, they did not fit my criteria, as I would like the database values be reflected in the front-end. Currently in my database, the implode() works, therefore (for example), if I check “Luxury”, “Brand”, “Retailer”, and press the “Submit” button, the three items “Luxury, Brand, Retailer” will be in that specified cell. It looks like my code works in the back-end, but these are my issues:

  1. I am not exactly sure (despite multiple Googles) how to retrieve those values stored in the single-cell array, and have it selected as “selected” (this would “check” the box in the front-end)

Could someone kindly take a look at my code below and let me know what seems to be missing/wrong/erroneous so I could attempt the revisions? Anything would be appreciated, thank you!

<?

if (isset($_POST['formSubmit2'])){
    $category = mysql_real_escape_string(implode(',',$_POST['category']));
    $accountID = $_POST['accountID'];

    mysql_query("UPDATE Spreadsheet SET category='$category' WHERE accountID='$accountID'");
}


$query = mysql_query("SELECT * FROM Spreadsheet LIMIT $firstRow,$rpp");

while($row = mysql_fetch_array($query)){  

// Begin Checkboxes

$values = array('Luxury','Brand','Retailer','B2B');

  ?>

<form name ="category" method ="POST" action ="" >

 <?

echo "<input type = 'hidden' name = 'accountID' value = '" . $row['accountID'] . "' >";
        for($i = 0; $i < count($values); $i++){
 ?>

 <input type="checkbox" name="category[]" value="<?php echo $values[$i]; ?>" id="rbl_<? echo $i; ?>" <? if($row['category'] == $i) echo "checked=\"checked\""; ?>/>
 <? echo $values[$i] ?><br>

 <? } ?>

        <input type ="Submit" name ="formSubmit2" value ="Submit" />
        </form>

 <? } ?>
  • 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-16T05:52:13+00:00Added an answer on June 16, 2026 at 5:52 am

    The best approach i can recommend given what you have is to, explode the values out of the db giving you a new array of all the select fields. Then use in_array to compare the list you have with this new list in the loop. then flag the checkboxs as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all thanks for taking the time to look into this. I store
thanks for taking the time to look at my question. I've been diving into
Thanks for taking the time to read this. I have an unknown number of
Thanks everyone for taking the time to read this. I have styled my navigation
First, thanks in advance for taking the time to read through this. I have
Thanks for taking the time to look at another of my questions. This seems
and thanks for taking a look at the question. The background I have several
Thanking you for taking the time to look at this question. The premise of
thanks for taking the time to stop by my question. Below you will find
Thanks in advance for taking the time to read my question. I'm using MySQL

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.