Page 1 of 1
SUBMIT variable -- how do I
Posted: Tue May 21, 2002 12:41 pm
by freewholly
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
Posted: Tue May 21, 2002 1:00 pm
by MattF
The way I use for things like this is to have a link on the end of each line with the row id, for example delete.php?id=$id
Just add that onto the end of your loop that I assume you have to dump your SQL query into a table.
Posted: Tue May 21, 2002 1:21 pm
by sam
I like the following:
form
Code: Select all
while($row = mysql_fetch_ass0c($result)){
// do your normal displey stuff.
echo "<input type=checkbox name="deleteї]" value="".$rowї"id"]."">";
}
action
Code: Select all
foreach($delete as $row){
if(mydql_query("DELETE FROM tablename WHERE id='".$row."'")){
echo "Entry ".$row." was deleted.";
}
}
I hope you understand the logic, it allows you to delete many rows at one time.
Cheers Sam
Posted: Tue May 21, 2002 1:53 pm
by freewholly
Thanks for the suggestions. I'll try them and see.
David