Results 1 to 3 of 3

Thread: latest articals script

  1. #1
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default latest articals script

    Hi,

    Can anyone help me with getting a php/mysql script where i can have the latest 10 + articals in the main page automatically without me editing the file everytime i add an artical/news!

    Would anyone be able to help me!!

  2. #2
    Join Date
    Oct 2008
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default

    careera,
    do you have anything for an example..code or website? i believe i can help, just need clarification. Well this might help..
    This will display the database and "LIMIT 10" will only display 10 only and "ORDER BY id DESC" will order the display according to your ID in the DESC order. All this can be found at w3schools
    PHP Code:
    <?php
    $con 
    mysql_connect("localhost","id","pass");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("db"$con);

    $result mysql_query("SELECT * FROM table LIMIT 10 ORDER BY id DESC");

    while(
    $row mysql_fetch_array($result))
      { 
    // Example of rows
      
    echo $row['FirstName'];
      echo 
    " " $row['LastName'];
      echo 
    " " $row['Age'];
      echo 
    "<br />";
      }

    mysql_close($con);
    ?>

  3. #3
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi and thanks, i'm glad someone is welling to help.

    To tell you the truth, i'm a beginer and I just want to know how to it because a friend asked me and I've been looking for some help but never got any.

    I'll look for the code or any files that is related and post it and may be you'll be able to assist.

    Thanks again.

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
  •