batch delete of data through html form/SQL
Posted: Thu Aug 17, 2006 8:06 am
feyd | Please use
The final_delete function obviously has to take each $memberid and run a query a simple 'DELETE from db where...' etc. So far my attempts have been unsuccessful. I do know for sure that each checkbox is actually obtaining the correct $memberid b/c I've looked at the source code on the form page. Any input would be GREATLY appreciated. Thanks!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello everyone,
I'm kind of new to PHP in general so please be gentle. I have a function that builds, within an html form, rows each consisting of a checkbox, firstname, and lastname. The idea is that you can check as many boxes as you want, hit a delete button, and then have the selections deleted out of the db. But I'm having trouble actually the info deleted. Here is the code that builds the form (this works fine).Code: Select all
<div class = "warning">
<em>WARNING</em>: Deleting a member cannot be undone!<br>
Select members for deletion.
</div>
<div class = "block_row">
<div class = "checkbox"></div>
<div class = "block"><b>Member ID</b></div>
<div class = "block"><b>First name</b></div>
<div class = "block"><b>Last name</b></div>
</div>
<form method = "POST" action = "">
<?
while (list($memberid, $firstname,$lastname) = mysql_fetch_row($delete_results)) {
echo "<div class = 'block_row'>";
echo "<div class = 'checkbox'><input type = 'checkbox' name = '$memberid'></div>";
echo "<div class = 'block'>".$memberid."</div>";
echo "<div class = 'block'>".$firstname."</div>";
echo "<div class = 'block'>".$lastname."</div>";
echo "</div>";
}
if(isset($_POST['submit'])) {
final_delete();
}
//////////The final_delete function obviously has to take each $memberid and run a query a simple 'DELETE from db where...' etc. So far my attempts have been unsuccessful. I do know for sure that each checkbox is actually obtaining the correct $memberid b/c I've looked at the source code on the form page. Any input would be GREATLY appreciated. Thanks!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]