PDA

View Full Version : How would I?



Frog!
13-10-2007, 07:55 PM
How would I delete an article via a link?
So an admin clicks a link and it will remove that post or row from the database.

redtom
13-10-2007, 08:11 PM
How would I delete an article via a link?
So an admin clicks a link and it will remove that post or row from the database.

The way I would do it is to make a collum in the table with an ID on auto increase, then I would fetch the data on a page display it with a link to "samepage.php?delete=$id" then I would just delete it from the table with a query, if you want I'll code it what I mean for you?

Frog!
13-10-2007, 08:14 PM
Get on msn redtom and I shall speak to you :D

Jamie.
13-10-2007, 08:19 PM
elseif ($_GET['news'] == deletenews) {
$q = mysql_query("SELECT * FROM news ORDER BY id DESC");
if ($_GET['id']) {
$news = mysql_query("SELECT * from news where id = '$_GET[id]'");
$news = mysql_fetch_array($news);
echo("<meta http-equiv='Refresh' content='1; URL=http://YOURSITE.COM/news.php?news=deletenews/'/>You have now deleted <B>$news[title]</B> posted by <b>$news[author]</b>");
$delete = mysql_query("DELETE FROM news WHERE id = '$_GET[id]'") or die(mysql_error());
}
elseif ($_GET['id'] == NULL) {
$q = mysql_query("SELECT * FROM news ORDER BY id DESC");
while($r=mysql_fetch_array($q)){
echo("$r[title] - $r[author] - $r[postdate] - <a href=\"http://YOURSITE.COM/news.php?news=deletenews/$r[id]/\">Delete</a><br>");
}
}
//ends the while func.
}
// ends the elseif for delete news
Think that would basically be it I fetched it out of my site ;)

Want to hide these adverts? Register an account for free!