02-06-2009, 10:03 PM
|
#2 (permalink)
|
|
The Wanderer
Join Date: Nov 2007
Posts: 13
Thanks: 0
|
The way I read this is that you have the 3 records, and a form where you want to be able to update the status for all three at the same time? You would need to give each input element a unique name that allows you to figure out which record it goes with.
Make your form like this:
HTML Code:
<select name="status[]">...</select>
<input type="text" name="deadline[]" />
<input type="hidden" name="ids[]" value = "1" />
<select name="status[]">...</select>
<input type="text" name="deadline[]" />
<input type="hidden" name="ids[]" value = "2" />
<select name="status[]">...</select>
<input type="text" name="deadline[]" />
<input type="hidden" name="ids[]" value = "3" />
This will create an array of the statuses, deadlines and row IDs. In your php, then use this:
Code:
for (i=0;i<count($_POST['status']);i++){
$status = mysql_real_escape_string($_POST['status'][$i]);
$deadline = mysql_real_escape_string($_POST['deadline'][$i];
$user = $_GET['user'];
$id = floatval($_POST['ids'][$i]);
mysql_query("update tbl_userpackage set status = '$status', deadline = '$deadline' where hash = '$user' AND id = $id");
}
--Andrew
|
|
|
|