nezbo Posted July 4, 2007 Share Posted July 4, 2007 Hi all I have this code and i want to beable to when i click the delete link to delete the row that is selected in the database? Any help please? $result = mysql_query("SELECT * FROM person ORDER BY UserName ASC"); echo "<table border=1 align=center>"; echo "<tr><td colspan=8 align=center><h2>All users registered with the system.</h2><tr><td>"; while ($row = mysql_fetch_array($result)) { echo "<tr><td align=left><a href=editUser.php?user_identifier=$row[CallID] >$row[CallID] </a>" . "</td><td align=left>" . $row['UserName'] . "</td><td align=left>" . $row['FullName'] . "</td><td align=left>" . $row['EmailAddress'] . "</td><td align=left>" . $row['ContactNumber'] . "</td><td align=left>" . $row['UserLevel'] . "</td><td align=left> <a href=#>Delete</a>" . "</td></tr>"; } echo "</table>"; Neil Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 4, 2007 Share Posted July 4, 2007 Well im guesing that your 'CallID' field is a unique field? If so, just pass that into the query string, as you do for your editUser.php page, and delete the row: <?php $id = $_GET['CallID']; mysql_query("DELETE FROM `person` WHERE `CallID`='$id'") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
nezbo Posted July 4, 2007 Author Share Posted July 4, 2007 cool cheers does this mean i need to creat a form type of thing to instrd of using a <a href.... ? Well im guesing that your 'CallID' field is a unique field? If so, just pass that into the query string, as you do for your editUser.php page, and delete the row: <?php $id = $_GET['CallID']; mysql_query("DELETE FROM `person` WHERE `CallID`='$id'") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 4, 2007 Share Posted July 4, 2007 No not at all. Get variables are passed to a page in the URL. If you specify the form method as get, all it actually does it put the contents of the form in the url. You would make your links something like: echo "<a href='deleteuser.php?id=$row[CallID]'>$row[CallID]</a>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.