Results 1 to 4 of 4

Thread: How would I?

  1. #1
    Join Date
    Nov 2006
    Location
    Cheshire.
    Posts
    730
    Tokens
    250

    Default How would I?

    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.


    Give us an add like!

  2. #2
    Join Date
    Jul 2005
    Location
    North Wales
    Posts
    4,233
    Tokens
    2,009

    Latest Awards:

    Default

    Quote Originally Posted by Frog! View Post
    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?

  3. #3
    Join Date
    Nov 2006
    Location
    Cheshire.
    Posts
    730
    Tokens
    250

    Default

    Get on msn redtom and I shall speak to you


    Give us an add like!

  4. #4
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •