Forum Moderators: coopster

Message Too Old, No Replies

Simple News Script

         

jfred1979

7:43 pm on Oct 25, 2004 (gmt 0)

10+ Year Member



I'm a PHP newbie, I've created a simple PHP script which uses mysql to update a news page. I basically took this from a tutorial I found online. Here's the basics, which takes the news and title variables from a form.

<?
$news = $_POST["news"];
$title = $_POST["title"];

mysql_connect("localhost","name","pass");
mysql_select_db("dbname");

$addnews =MYSQL_QUERY("INSERT INTO news (id,title,news)". "VALUES ('NULL', '$title', '$news')");

echo("News Added!");
?>

Is there something similar to the

MYSQL_QUERY("INSERT INTO news (id,title,news)". "VALUES ('NULL', '$title', '$news')");

line that I can use to delete an entry, instead of add one?

robho

9:56 pm on Oct 25, 2004 (gmt 0)

10+ Year Member



MYSQL_QUERY("DELETE FROM news WHERE id = '$id' ");

You'll need to work out how to find the id of the news item before you can delete it of course, presumably you already display it near the news item.