Unholy Prayer Posted February 7, 2007 Share Posted February 7, 2007 Ok, I'm writing a support script for my website which includes an admin area where admins can delete the support complaints but right now it's only with links. How would I make it so it displays a check box that would delete only the checked complaint? This is my code: <?php require_once('config.php'); include('includes/header.tpl'); $act = $_GET['act']; if($act=='') { echo "<td align='center' class='content'><table align='center' width='50%' cellspacing='0' cellpadding='2' border='0'> <tr>"; $result = mysql_query("select * from support"); while($r=mysql_fetch_array($result)) { $id=$r["id"]; $username=$r["username"]; $email=$r["email"]; $content=$r["content"]; echo "<td align='left' colspan='2'>$username says:</a></td> </tr><tr> <td align='left' colspan='2'>$content<br><br></td> </tr><tr> <td align='left'><a href='support.php?act=delete&id=$id'>Delete</a></td> <td align='right'><a href='mailto:$email'>Reply to Complaint</a><br><br></td> </tr><tr>"; } echo "</table></td>"; } $sid = $_GET['id']; if($act=="delete") { $sql = "DELETE FROM support WHERE id=$sid"; $result = mysql_query($sql); echo "<td align='center'>The complaint has been deleted.<br>Click <a href='support.php'>here</a> to return to the support management page.</td>"; } ?> Link to comment https://forums.phpfreaks.com/topic/37386-delete-database-result-with-checkbox/ Share on other sites More sharing options...
jcbarr Posted February 7, 2007 Share Posted February 7, 2007 You would have to use a form. Have the form feed the script the id of the record to be deleted (much like you are doing now). If you would want more than one then you can catch them in an array and use a while loop to then delete all of them that were passed to the script. Sorry but I don't have time to write type the whole code out. Link to comment https://forums.phpfreaks.com/topic/37386-delete-database-result-with-checkbox/#findComment-178722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.