473,597 Members | 2,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating multiple checkbox entries into php mysql database

63 New Member
Hi All..'mAtif..i' ve got stuck within checkboxes these days..i've got many input items like checkboxes,text area and along with them there are many checkboxes...al l the data except the checkbox's is comfortably getting entered into the database but the real problem is with the checkboxes..onl y 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 7005
Markus
6,050 Recognized Expert Expert
Strange...

=\
this has happened on both of your threads..
Dec 7 '07 #2
TechnoAtif
63 New Member
ya.it is atrange...plz help ..how culd i find its soluiton
Dec 8 '07 #3
rizwan6feb
108 New Member
This could help u.Check this
May 21 '08 #4
Atli
5,058 Recognized Expert Expert
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 Recognized Expert Expert
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
10640
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: imageID image_order I want to be able to modify the image_order column where imageID = imageID.
15
7375
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 atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
7
2489
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 doing is saving the local file as a backup. Then I have to edit the backup, deleting the create file info and all previously uploaded entries before I can import the text file to the server. Is there an easier way to do this so I won't get...
2
3241
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 of the records. They would click the checkbox and hit a "delete" button. Then the database would be updated and the user redirected back to the page that would now show all the records that weren't deleted. Sort of like Yahoo mail, you get a list...
6
1677
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, and I want to delete 3. How do I do this? -- Kind Regards
33
3296
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 of 20 steps) On the admin page the steps are listed, in "order" order and the user can create new steps and assign an order and all is well. The problem may come in using a renumber function which should take the steps in their current order...
10
2224
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 an array of checkboxes, but my update loop is not working. Here is my code: /*---------This retrieves the records -------------*/ if($row_md) { do{ echo "<tr><td text align='right'>";
2
2631
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 working today) I have EasyPHP2.0b1 Apache/MySQL server installed on my Windows XP(SP2) machine. This runs Apache 2.2.3, MySQL 5.0.27 and PHP 5.2.0 I have a PHP code filled listbox, which allows multiple selections. Actual Values are "rcd_no, cn_no"...
0
3100
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td colspan="2"><p>
6
1805
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 product_number
0
7886
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8272
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6688
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.