
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","user","password");
//select which database you want to edit
mysql_select_db("spoono_news");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("select * from news order by id");
//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the news
$title=$r["title"];//take out the title
$id=$r["id"];//take out the id
//make the title a link
echo "<a href='delete.php?cmd=delete&id=$id'>$title - Delete</a>";
echo "<br>";
}
}
?>
And that is basically all the code we have to write to find the ID for which one you want to delete. Now here is the processing in English:
<?
if($_GET["cmd"]=="delete")
{
$sql = "DELETE FROM news WHERE id=$id";
$result = mysql_query($sql);
echo "Row deleted!";
}
?>
You can see my code that I worked on and made sure worked by right clicking and saving delete.txt. Not too tough was it? Well thats it folks. I hope it works out for you and if it doesn't, email for help at webmaster@spoono.com and we'll try to help you out.
Copyright © 2000-2008 Spoono, LLC. All rights reserved.
Network: Reseller Web Hosting by Spoono Host | Spoonloads | Absolute Cross
Terms of Service | Privacy Policy.