Jump to content

Deleting a row


alen

Recommended Posts

Normally I don't do this but its easier than typing out all the instructions:
[code]<html>
<body>
<?
mysql_connect("localhost","nancy","ehgxsjhn");

mysql_select_db("nancy");

if(!isset($_GET["cmd"]))
{
  $result = mysql_query("select * from news");
 
  while($r=mysql_fetch_array($result))
  {
      $title=$r["title"];
      $id=$r["id"];
   
      echo "<a href='delete.php?cmd=delete&id=$id'>$title - Delete</a>";
      echo "<br>";
    }
}
if($_GET["cmd"]=="delete")
{
    $sql = "DELETE FROM news WHERE id=" . $_GET["id"];
    $result = mysql_query($sql);
    echo "Row deleted!";
}
?>

</body>
</html>[/code]

Try that out.
Link to comment
https://forums.phpfreaks.com/topic/30710-deleting-a-row/#findComment-141509
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.