SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    list of records!?!

    Just a simple Q?

    How do I get my php script to list all records from same db table. Lets say that I have 3 records in a table, and I want to list them all in a horisontal row. I know how to get a single record, but can't seem to find out how to make it loop through the records...Simple I hope...

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the following will work
    PHP Code:
    $sql "SELECT * FROM table";
    $result mysql_query($sql);
    if (!
    $result) {
        die (
    '<p>Error performing query: ' .
             
    mysql_error() . '</p>');
    }
    else {
    while (
    $row mysql_fetch_array($result))
    {
    //whatever html you stick in here will repeat for how many rows it returned



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
  •