Storing an unchecked checkbox value in mySQL
I have an array of checkboxes whose values if checked can be updated in mysql. The code I have below accomplishes that just fine.
On my form I have:
The above code displays various items with a checkbox next to them. So if that checkbox is checked the code below stores that in mysql.
On my update.php page I have:
The problem is though i can check a checkbox and store that value '1' in mysql, I have no way of unchecking an already checked checkbox and storing the '0' in mysql.
Can anyone help?
Thanks in advance
Easy. Before running your loop set ALL of the records to 0 and then loop through the selected checkboxes and set those to 1.
The only snag is that if you have records you want to keep set as 1 you'll be stuffed unless they were also selected in the form.
Apart from that you can't do it. Checkboxes are for selecting items not for changing their state. Thats what radio buttons are for.
Can anyone Help in Updating database field valu to 0 when a check box is unchecked and submitted.
i need in php...
thanks in advance
|All times are GMT +1. The time now is 08:19 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.