Can you all tell me a good way to maintain data on my site? I have created a maintenance screen to Add, Edit and Search elements in the database. Delete, for me, is more difficult. I would like to add a Delete button to the Search results (one per row, or if it is cleaner, a checkbox per row instead of a button), but I don't know how to tell which row is to be acted upon. In other words, I can't tell which Delete button was clicked or which rows were checked. Do you have any advice?
David
SUBMIT variable -- how do I
Moderator: General Moderators
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
I like the following:
form
action
I hope you understand the logic, it allows you to delete many rows at one time.
Cheers Sam
form
Code: Select all
while($row = mysql_fetch_ass0c($result)){
// do your normal displey stuff.
echo "<input type=checkbox name="deleteї]" value="".$rowї"id"]."">";
}Code: Select all
foreach($delete as $row){
if(mydql_query("DELETE FROM tablename WHERE id='".$row."'")){
echo "Entry ".$row." was deleted.";
}
}Cheers Sam
-
freewholly
- Forum Newbie
- Posts: 3
- Joined: Thu May 09, 2002 3:05 pm