Results 1 to 3 of 3

Thread: last 3 added

  1. #1

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909

    last 3 added

    Okay I have a page with three 1 cell tables. Also i have a mysql database with a column called "Title" and 1 called "id" which is auto-increment. I want to get the last last 3 id in the database and put each of those 3 "Titles" in each table I have. Know I don't know how to get all of the last 3 and each title in each table. Plz help me

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Like this:

    Code:
    $result = mysql_query("SELECT * FROM table ORDER by id DESC LIMIT 3 ");
    
    if ($record = mysql_fetch_array($result)) {
        do {
            echo $record['id'] . "<br>\n";
        } while ($record = mysql_fetch_array($result));
    } else {
        echo "No records found!";
    }
    Or something to that extent.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    Thanks I think it will work great.
    Last edited by stickman373; Aug 14th, 2002 at 08:37 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width