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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:57:34+00:00 2026-06-15T19:57:34+00:00

Currently, I have a piece of code which displays four checkboxes and allows a

  • 0

Currently, I have a piece of code which displays four checkboxes and allows a user to select the checkboxes, click submit, and the data, through the POST method, will be sent to the database (called “Spreadsheet”) where it would be stored.

Typically, with a radio button, the data stored is only one element. But I noticed that with checkboxes, the elements (for my case specifically) could range from zero to four items. So my issue with my code is, only one element gets stored, even if I press all four. I think I have to store the items as an array, but how do I store + retrieve said items to and from the database?

Below is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html> <!--  tells browser this is an HTML document -->
<head> <!-- container of all head elements --> </head>
<body> <!-- Begin the content of the document -->

<?

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

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

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

$values = array('0 - Luxury','1 - Brand','2 - Retailer','3 - 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_0" <? if($row['category'] == $i) echo "checked='checked'"; ?>/>
 <? echo $values[$i] ?><br>

 <? } ?>

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

</body>
</html>
  • 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-15T19:57:35+00:00Added an answer on June 15, 2026 at 7:57 pm

    Instead of passing in name=”category”, set it to “$category[]”.

    You should be able to retrieve it from $_POST, set it to a new variable, and manipulate it how you want.

    if (isset($_POST['formSubmit2'])){
    
       $submitted_category = $_POST['$category'];
       $accountID = $_POST['accountID']; 
    
       // rest of your code...
    
    }
    

    Hope that helped.

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

Sidebar

Related Questions

I have been trying to optimize some code which handles raw pixel data. Currently
I'm currently facing a large piece of legacy code which I have to understand
I have this piece of code which reads and displays input strings until a
I currently have this piece of code: NSString *strURL = [NSString stringWithFormat:@http://www.sample.com /phpFile.php?firstname=%@,txtfirstName.text]; NSString
I currently have the following piece of code NSPredicate *pred = [NSPredicate predicateWithFormat:@SELF contains
I am currently working a piece of code which needs to send an attachment
Here's the piece of code I currently have: int main () { int pid,
I currently have a piece of code in my Android application that picks up
I have a piece of C++ code which reads out the text of a
I have the following piece of code which gets the following results. $file =

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.