Korona Posted July 20, 2009 Share Posted July 20, 2009 Hi, I am making a php/mysql page and everything works but delete function. When I hit "delete" link at a row, the page doesn't delete that row but next or previous one. here's the code: <?php include("ini.php"); $result = mysql_query("SELECT id, playersname, age, address FROM mytable ORDER BY id ASC",$connect); echo "<table>"; while($myrow = mysql_fetch_array($result)) { $id = $myrow["id"]; $playersname = $myrow["playersname"]; $age = $myrow["age"]; $address = $myrow["address"]; if ($task=="del") { $sql = "DELETE FROM mytable WHERE id=$id"; $result = mysql_query($sql); echo "Row deleted!"; } echo "<tr><td><p><a href=\"player.php?id=$id\">$playersname</a></p></td><td><p>$age </p></td><td><p>$address</p></td><td><p><a href=\"playerslist.php?id=$id&task=del\">Delete</a></p></td></tr>"; } echo "</table>"; ?> Thank you in advance for help Quote Link to comment https://forums.phpfreaks.com/topic/166561-weird-delete-problem-the-code-deletes-everything-but-selected-record/ Share on other sites More sharing options...
kickstart Posted July 20, 2009 Share Posted July 20, 2009 Hi You do not appear to be checking any passed in variables to determine whether you are doing a delete or what id to delete. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/166561-weird-delete-problem-the-code-deletes-everything-but-selected-record/#findComment-878461 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.