Need to make a direct link to a constantly changing URL

Discussion in 'PHP' started by aj22, Jan 15, 2007.

  1. #1
    I have a php script that posts news articles and assigns them this link:

    /news.php?action=fullnews&id=9

    id increases +1 with every posted article. Does anyone know a way how I can make a direct link to the latest posted article?
     
    aj22, Jan 15, 2007 IP
  2. West

    West Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If this is MySQL based just do something along the lines of this.

    
    $query = mysql_query("SELECT * FROM `articles` ORDER BY `id` DESC LIMIT 0, 1");
     $article_t = mysql_fetch_array($query);
     $last_article = $article['id'];
    
    PHP:
    Then your link would be something along the lines of.

    
    $link = "<a href='http://yoursitecom/news.php?action=fullnews&id=".$article['id']."'>LINK TEXT</a>";
    
    PHP:
    Hope this helps.
     
    West, Jan 15, 2007 IP
  3. aj22

    aj22 Peon

    Messages:
    643
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Perfect, thank you so much West.
     
    aj22, Jan 16, 2007 IP
  4. West

    West Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Anytime. :)
     
    West, Jan 16, 2007 IP