I've looked through some tutorials on how to delete multiple rows in a database with checkboxes displayed on a website, and have the following general code:
Code: Select all
<input type="checkbox" name="del[]" value="$recordid">
// in another file:
foreach ($del as $row_id) {
mysql_query("DELETE FROM table WHERE id = '$row_id'");
}
Here's the catch however. The above code assumes that the first row has an ID of 1, the second an ID of 2, etc. However, my rows are defined in a grading database by the students ID number, so they could be an arbitrary number. For instance, right now, the first row has a student ID of 13, but that could change to any number at any given time. How would I go about doing this?
I tried:
<input type="checkbox" name="$Student_ID" value="$recordid">
But that didn't work either.