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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:25:42+00:00 2026-05-23T07:25:42+00:00

i want insert this form value to datanase : <input type=checkbox name=brand1 id=brand1 value=1>

  • 0

i want insert this form value to datanase :

<input type="checkbox" name="brand1" id="brand1" value="1"> <label for="brand1">Brand 1</label>
<input type="checkbox" name="brand2" id="brand2" value="1"> <label for="brand2">Brand 2</label>
<input type="checkbox" name="brand3" id="brand3" value="1"> <label for="brand3">Brand 3</label>
<input type="checkbox" name="brand4" id="brand4" value="1"> <label for="brand4">Brand 4</label>
<input type="checkbox" name="brand5" id="brand5" value="1"> <label for="brand5">Brand 5</label>

these text box are get by php from a table in database and may be Variable

i want insert to database by this format
if brand 1 are checked $brand=”1,”;

and Finally like this :

insert($name,$brands); and $brands = "1,2,3,4,5,";

if write this by if and while but it doesn’t work because if insert run in while {} Five times insert Done and if insert run out of while {} , $brand = “5,”

thanks for your help or idea for this problem

it’s mean :

<form method="post" action="#">
<?php
$result = $db->getall(brands);
        if(!empty($result)) {
    while ( list($key,$val)=each($result) ) {
        $brand_id = stripslashes($val["id"]);
        $brand_name = stripslashes($val["name"]);
    ?>
    <input type="checkbox" name="brand<?php print"$brand_id"; ?>" value="1" style="cursor:pointer;"><label for="brand<?php print"$brand_id"; ?>" style="cursor:pointer;"> <?php print"$brand_name"; ?></label>
    <?php }} ?>

Source Output:

<input type="checkbox" name="brand1" value="1"> <label for="brand1">Brand Name 1</label>
<input type="checkbox" name="brand2" value="1"> <label for="brand2">Brand Name 2</label>
<input type="checkbox" name="brand3" value="1"> <label for="brand3">Brand Name 3</label>
<input type="checkbox" name="brand4" value="1"> <label for="brand4">Brand Name 4</label>
<input type="checkbox" name="brand5" value="1"> <label for="brand5">Brand Name 5</label>
<input type="submit" value="Submit" />
</form>

when submit form , insert source is :

    <?php
$result = $db->getall(brands);
        if(!empty($result)) {
    while ( list($key,$val)=each($result) ) {
        $brand_id = brand.stripslashes($val["id"]);
        $brand_name = stripslashes($val["name"]);
    $brand_ids = "brand.$brand_id";
    if($$brand_ids==1) {$brands="$brandid,"}

}} ?>
$db->add_submenu("$brands"); 
  • 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-23T07:25:42+00:00Added an answer on May 23, 2026 at 7:25 am

    You should change the name of your checkboxes to brand[]. It will give you an array once submitted at $_POST['brand']

    Ex. 
    
    <input type="checkbox" name="brand[]" value="1" ... />
    <input type="checkbox" name="brand[]" value="2" ... />
    <input type="checkbox" name="brand[]" value="3" ... />
    <input type="checkbox" name="brand[]" value="4" ... />
    <input type="checkbox" name="brand[]" value="5" ... />
    

    on the other side you can either do something like the following:

    // this will return '1, 2, 3, 4, 5' when all are selected. 
    $index = implode(", ", $_POST['brand']); 
    

    and at that point you will have the brands in comma delimited form.

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

Sidebar

Related Questions

This is the input string 23x * y34x2 . I want to insert *
I have following code: <input type=hidden name=qz_id value=<?=$quizid; ?> /> <input type=hidden name=s_id value=<?=$s_id;
I want to insert this margin, but I don't know why... I want it
I am using Python MySQLDB, and I want to insert this into DATETIME field
I want to do something like this INSERT INTO t (t.a, t.b, t.c) VALUES
I want to insert a vector into a set like this: set<vector<prmEdge> > cammini;
I have a vector that I want to insert into a set . This
This is the part of a string 21xy5. I want to insert * surrounded
I want to insert a value from the database into my dropdown menu in
Hello everyone I am completely stuck with this problem. I want add the name

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.