I for the life of me can't get this to work and I get no errors.
admin.php
<html>
<head>
<title>Admin Area</title>
</head>
<body>
<?
//connect to mysql
//change user and password to your mySQL name and password
$conn = mysql_connect("host","username","password");
if (!$conn)
{
die('Could not connect to the database: ' . mysql_error());
}
mysql_select_db("database", $conn);
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the posts
$result = mysql_query("SELECT * FROM posts ORDER BY id");
//run the while loop that grabs all the post scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the post
$topic=$r["topic"];//take out the topic
$name=$r{"name"];//take out the name
$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>";
}
}
?>
</body>
</html>
delete.php
<?
if($_GET["cmd"]=="delete")
{
$sql = "DELETE FROM posts WHERE id='$id'";
$result = mysql_query($sql);
echo "Post deleted!";
}
?>
Obviously I will not post my host information here so those are just placeholders for mysql and I know they work.