Jump to content

Deleting a row


alen

Recommended Posts

I made this script that's supposed to delete a row when I click on one of the news titles..

I added two threads, Hello world and Test.

I simply want to delete Test. But when I click on the link nothing happends.

Here's the code:

http://anigma.sitees.com/delete.txt
Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.