![]() |
Checkbox mass update?
Hi,
I've built an approval process for submitted messages with an approve or delete button next to each message. This links through to either: url.php?approve=$id url.php?delete=$id But i want to change them from links to checkboxes so that i can update multiple records at once. How would i go about this? Thanks, Mike |
Make your form dynamically and run through it with a forloop. Like;
Code:
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">So, if you want to mass update it, simply put in a forloop; PHP Code:
|
Maybe it's just paranoia but I would clean the input first..
|
Quote:
|
Thanks for the advice guys, will make sure put a stop to that sql injection and will let you know if i have any problems with the rest of the script :)
|
ok i'm running into a little problem...
I have set all of the check boxes to: PHP Code:
PHP Code:
PHP Code:
Thanks |
The
value property of each checkbox should be set to the actual id of each item, and not to an array (id[]).HTML Code:
<input type="checkbox" name="checkbox[]" value="<?= $id ?>" />To process the form data you use $_POST['checkbox'][$i]:PHP Code:
|
Perfect, got that working great now.
Thanks guys! :) |
Quote:
So yes, paranoia. Hopefully it'll work out oMIKEo! /edit I just noticed in your mysql_query() that you set the value with "Y" and perhaps "N". I advise you to set the field to int(1) and put a 0 for no, and a 1 for yes. That way, the system would be more secure and you wouldn't have to mess with upper or lower case characters. |
Quote:
BOOLEAN / BOOL data type which you can use, where zero is false and non-zero is true. Storing true/false values within an INT column is a complete waste of space since that type uses four bytes. BOOL (or even TINYINT) only requires one byte. Specifying INT(1) does not restrict the range of allowed values to one byte in length (0-255 unsigned). |
| All times are GMT. The time now is 04:20 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0