473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How To Insert Multiple Check Box Values into MySQL Database ?

10
hello every one pls tell me how can i save multiple checkbox value into database.

I have created one table into the database named Category_Table and another table named CategoryTitle.
for e.x.

1.Graphics and Animation(From Category_Table)

1.Concept Artist(From CategoryTitle Table)
2.Animator
3.Stereographer
4.Compositor
2.Sound

1.Sound Assistant
2.Sound Engineer

So what i am doing here is m calling these values from the database in a checkbox.

Expand|Select|Wrap|Line Numbers
  1. while($category_id <= 30)
  2.     {
  3.     $result = mysql_query("SELECT * FROM category_tbl where category_id = $category_id ");
  4.     $row = mysql_fetch_assoc($result);
  5.     echo '<div id="main">';
  6.     echo '<div class="content">';
  7.     echo '<div class="title">';
  8.     echo $row['category'];
  9.     echo '</div>';
  10.     echo '<div class="image"><button onclick="toggle5(showDiv'.$category_id.')" ><strong>Expand</strong></button>';
  11.     echo '</div>';
  12.     echo '<div id="showDiv'.$category_id.'" style="display:block">';
  13.  
  14.         $cat_title = mysql_query("SELECT * FROM category_title_tbl WHERE category_id = '$category_id'") or die (mysql_error()); 
  15.             while ($cat_tit=mysql_fetch_array($cat_title))
  16.             {?>             
  17.              <input type="checkbox" value="$cat_tit['category_title']" id="cat_title" />
  18.              <?php echo $cat_tit['category_title'];
  19.              echo '<br />';
  20.  
  21.             }   
  22.     echo '</div>';
  23.     echo '</div>';
  24.     echo '</div>';
  25.     $category_id = $category_id + 1;
  26.     }
so what i want is when user select multiple checkboxes then those values get insert into the database...

pls tell me how can i do this...

plsss rply..
May 28 '13 #1

✓ answered by Ammu

Expand|Select|Wrap|Line Numbers
  1. $x = array();
  2. for($i=0;$i<=count($_POST['cat_title']);$i++) 
  3.    {
  4.     $x .= $_POST['cat_title'][$i]."|";
  5.    }
  6.  
print_r($x);
You will get a string like category_title1|category_title2|category_title3|.. ...........

3 17740
Ammu
78
Expand|Select|Wrap|Line Numbers
  1.  <input type="checkbox" value="<? echo $cat_tit['category_title']; ?>" id="cat_title" name="cat_title[]" />
and you can take values
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['submit']))
  2. {
  3.   for($i=0;$i<=count($_POST['cat_title']);$i++)
  4.  
  5.    {
  6.     echo $_POST['cat_title'][$i];
  7.    }
  8. }
  9.  
May 31 '13 #2
ROXIT
10
hey thanks ammu its working but how can i collect those values to an array and insert into database.
May 31 '13 #3
Ammu
78
Expand|Select|Wrap|Line Numbers
  1. $x = array();
  2. for($i=0;$i<=count($_POST['cat_title']);$i++) 
  3.    {
  4.     $x .= $_POST['cat_title'][$i]."|";
  5.    }
  6.  
print_r($x);
You will get a string like category_title1|category_title2|category_title3|.. ...........
May 31 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
2
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure...
5
by: r_o | last post by:
hi, im somehow new to web development, im developing an application with ms access 2003 using asp i want to know if there's a way to make a bulk insert into the database using the recordset...
4
by: grouchy | last post by:
hello all, not sure if i fully explained myself on an earlier post. All i really need to do is to store an xml file into mysql database. I have no idea how to do this, including any php code i...
3
rajiv07
by: rajiv07 | last post by:
Hi to all, We can store image in mysql using MEDIUMBLOG data type.I want to know how to insert or select and store an image data type using perl. Is any idea Please Thanks. Regards ...
1
by: soulr | last post by:
Hi, I've been working on a big application lately, and I could use some help. I use MySQL database and visual studio with visual basic as a language. The thing is I've reached where I need...
1
by: JSharma | last post by:
Hii Everyone I am having a problem while inserting the checkbox values into database after posting. I am actually getting the Checkbox fields from Database .Now I want to insert the Checked field...
1
by: jan reiner | last post by:
good day everyone.. i am doing a project for my school i am having difficulties in inserting data in mysql and also inserting multiple data in just a submit button.. can anyone help me in this?...
1
by: apssiva | last post by:
Hi, how? id,username,subject 1,AAAA, EnglishI 1,AAAA, MathsI 1,AAAA, MathsII 1,AAAA, EnglishII
1
by: Aruna Dalvi | last post by:
I'm using Vb.Net and odbc Server I have a Listbox that users can select multiple values. Selection Mode = Multiple. The multiple values are associated with one record. I need to insert into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.