Results 1 to 6 of 6

Thread: listing all records?

  1. #1

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

    listing all records?

    How can i loop through all the records in a table called movie and print the info in a table for just the field Title?

    Example:

    Rows look like this in the database

    row1: Title Review Image Comments

    so i want to print out the Title field for all the rows in a table 1 in each cell. Also is there a way to say put 20 on each page?

    thanks for da help

  2. #2
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    PHP Code:

    <?php
    $db 
    mysql_connect("localhost""root");
    mysql_select_db("yourdb",$db);
    $result mysql_query("SELECT * FROM yourtable",$db);
    while (
    $myrow mysql_fetch_array($result)) {

    $title=$myrow["title"];

    //add some html to make it table like
    print("$title<br>");

    }

    ?>

  3. #3

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    doesn't seem to list anything when I try it. And yes I did change the info to work with my db, but i get a blank page

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    what is your code, because that should have worked.

  5. #5

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

    <?php
    $db 
    mysql_connect("localhost""stickman373""******");
    mysql_select_db("stickman373_uk_db",$db);
    $result mysql_query("SELECT Title FROM movie",$db);
    while (
    $myrow mysql_fetch_array($result)) {

    $title=$myrow['Title'];

    //add some html to make it table like
    print("$title<br>");

    }

    ?>
    The Above code works, but the below code does not. Why all I change is what is selects from the movie table?

    PHP Code:
    <?php
    $db 
    mysql_connect("localhost""stickman373""******");
    mysql_select_db("stickman373_uk_db",$db);
    $result mysql_query("SELECT * FROM movie",$db);
    while (
    $myrow mysql_fetch_array($result)) {

    $title=$myrow['Title'];

    //add some html to make it table like
    print("$title<br>");

    }

    ?>

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    there is nothing wrong with any of that code. it should run on both of them.

    did you restart your computer to see if the cache isn't making it bug up? I see nothing wrong with the code.

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