SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict mh8759's Avatar
    Join Date
    Jun 2000
    Location
    Slovenia, Europe
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I have a database of articles with columns ID,Title,Text,Date etc..

    I want to pull out certain number of articles that were added the last, for instance last articles. Then I want to display the title and text of the last one(or the most recent one if you want), while for other three I want to show only Date and Title.

    It should look like this:

    Title of the last one added into the database

    Text...blablalblalbla...blalbla...
    Text...blablalblalbla...blalbla...

    10.11.2000 Some title
    5.11.2000 Some title
    3.11.2000 Some title

    All these three should have links to the whole article.

    I know I can pull out entries with
    query = mysql_query(SELECT ID,Title,Text,Date FROM Articles WHERE CatID=2 ORDER BY Date DESC LIMIT 4), but I don't know how to access article by article. Are they stored in an array?

    Any help would be appreciated,
    thanks
    Mare












  2. #2
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php
    $news_query = mysql_query("SELECT * FROM Articles WHERE CatID=2 ORDER BY Date DESC LIMIT 4");

    while ($row = mysql_fetch_array($news_query))
    {
    $id=$row["ID"];
    $title=$row["Title"];
    $text=$row["Text"];
    $date=$row["Date"];
    echo ("- <a href=http://www.you.com/articles.php?ID=$id>$title</a> - $date<br>");
    }
    ?>


    Read a tutorial before you post in the future. There is a good one at sitepoint.com
    Nate Gross
    DarkOps.com

  3. #3
    SitePoint Addict mh8759's Avatar
    Join Date
    Jun 2000
    Location
    Slovenia, Europe
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks!


Bookmarks

Posting Permissions

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