473,396 Members | 2,010 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,396 software developers and data experts.

updating multiple checkbox entries into php mysql database

Hi All..'mAtif..i've got stuck within checkboxes these days..i've got many input items like checkboxes,textarea and along with them there are many checkboxes...all the data except the checkbox's is comfortably getting entered into the database but the real problem is with the checkboxes..only one entry is being stored ...but i want to enter the multiple entries from the checkboxes to enter into the database...the form is a voting poll..and i have made use of arrays..but i'm not able to get the right way of how to enter the multiple checkbox entries into mysql..plz help..the code follows...It has two tables...the updata checkbox data is to be entered into the 'tally' table... .More than one votes can be dne through checkboxes and as they are checked,there entry should be made into the table..plz help.as quick as possible..thanx in advance...the code follows:

<Code removed>
Dec 7 '07 #1
5 6940
Markus
6,050 Expert 4TB
Strange...

=\
this has happened on both of your threads..
Dec 7 '07 #2
ya.it is atrange...plz help ..how culd i find its soluiton
Dec 8 '07 #3
rizwan6feb
108 100+
This could help u.Check this
May 21 '08 #4
Atli
5,058 Expert 4TB
Hi.

I have removed the 519 lines of code you posted.
Such a large amount of code can not be handled correctly, making you post appear empty.
Try posting an "example" of your code, perhaps the areas you feel will be most useful to us.

And besides that, 519 lines of code will scare most readers away ^^
May 21 '08 #5
Atli
5,058 Expert 4TB
If you have multiple check-boxes, all named the same, followed by [], each representing an ID of a vote you want updated, you can accept them in PHP as an array.
You can use that array to build a list of ID's that need to be updated, and pass that into an IN() clause in your SQL.

For example:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['submitted'])) {
  3.   # Connect to the database
  4.   # ... You know the drill
  5.  
  6.   # Get the votes and *implode* them into a list
  7.   $votes = $_POST['vote'];
  8.   $voteList = implode(", ", $votes);
  9.  
  10.   # Create a query, using the list in a IN() clause
  11.   $SQL = "UPDATE tally SET tvote = tvote + 1 WHERE nid IN ({$voteList})";
  12.   echo "<pre>", $SQL, "</pre>";
  13. }
  14. ?>
  15.  
  16. <form action="?" method="post">
  17.   <input type="checkbox" name="vote[]" value="1" /> Vote 1 </br>
  18.   <input type="checkbox" name="vote[]" value="2" /> Vote 2 </br>
  19.   <input type="checkbox" name="vote[]" value="3" /> Vote 3 </br>
  20.   <input type="checkbox" name="vote[]" value="4" /> Vote 4 </br>
  21.   <input type="submit" name="submitted" />
  22. </form>
  23.  
May 21 '08 #6

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

Similar topics

2
by: scott | last post by:
Hi, I'm having some trouble with something that should be relatively easy. I want to update multiple rows in one of my database tables simultaneously. In my table I have these values: ...
15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
7
by: Paige | last post by:
I have a database on my local machine that I make entries and corrections on. I'd like to be able to upload that to my server and have that update the database that's on the server. What I've been...
2
by: dukeofwhelmsley | last post by:
Hello, I have a database generated form that I would like users to be able to update by selecting a checkbox. Say the page displayed has six records on it and the user wants to delete one or more...
6
by: Rudi Ahlers | last post by:
A different question though. Is it possible to delete duplicate entries, where the email address is the same, and only keep one? i.e.. I got say 4 DB entries, all with the same email address,...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
10
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
2
by: julie18881 | last post by:
I may be being really stupid here, i have spent the last 3 hours looking round your site and some other for answers to my problem, but have not had much luck (possibly cuase my brain just isn't...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
6
by: Al Moodie | last post by:
Hi, I have a MySQL database where I want to updated multiple records. The table has two columns: product_number product_price I have a list with first entry product_price, second entry...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.