assign delete for each row using sql query dynamically not specifying the row NAME or ID
I want to assign delete for each row using sql query but not specifying the row NAME or 开发者_StackOverflow社区ID, e.g.: $sql = "DELETE FROM $table
WHERE Description1 = 'Description 10'";
...must be dynamically maybe via row ID to delete correct row at any given time?
Please let me know if you want me to eloborate more about the question above, thanks in advance
If you want to delete all rows within one table just do the following:
DELETE FROM $table
Be careful! All rows will be deleted.
If you want to set the description for every row to an empty string just do:
UPDATE $table SET (Description1 = '')
Put checkboxes on each row with the ID of the relevant row as the value, and have these posted as an array when you click on the delete button. Then you can simply implode the array you get in PHP and use it in your delete statement as follows (you probably want to add some sanity checks on the posted data though):
$sql = 'DELETE FROM table WHERE ID IN(' . implode(',', $array) . ')';
精彩评论