I have a php page which shows some data form the database. This works like an Xl sheet where you can change the values. However the user should be able to save the changes made on the entire page by clicking one button and not individual save buttons for each row of records. This is the way i am doing it:
if ($POST[save])
{
for ($i=0; $i < $POST[ct]; $i++)
{
$j = $i+1;
$save_query = "UPDATE powerpack_material SET powerpack_finished_count='$fin_count[$i]', powerpack_raw_count='$raw_count[$i]', powerpack_status='$mat_status[$i]' WHERE powerpack_id = '$j'";
mysql_query($save_query) or die("$save_query");
unset($ct);
}
}
i am using $j to imply where to store the value. It works cos the id is an autoincrement field and is in ascending order (1,2,3,4,...). but if i delete one of the record in that table the chain will be broken and the update wont work. Can someon suggest a better way.