Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Retrieve data and display multiple pages

    I'm new at this. My needs exceed my current abilities. I would appreciate some help. I am retrieving data from my database and displaying the last 10 rows on a page. I would like to display all previous records rather than just the last 10. My code is as follows:

    #connect to MySQL
    $rs = @mysql_connect( "localhost", "user", "password" )
    or die( "Could not connect to MySQL" );

    #select the database
    $rs = @mysql_select_db( "my_database" )
    or die( "Could not select database" );

    #create the SQL query

    $sql = "select * from guestbook order by time desc limit 10";


    #execute the query
    $rs = @mysql_query( $sql )
    or die( "Could not execute SQL query" );

    #loop through all records
    while ( $row = mysql_fetch_array( $rs ) )
    {
    <table class="archive" border="1" width="375">
    <tr>
    <td><b>Name:</b> <?php echo $row["name"]; ?></td>
    </tr>

    <tr
    <td><b>Comments:</b> <?php echo $row["comments"]; ?></td>
    </tr>
    </table>
    <br>
    }


    How do I create multiple pages that contain all retrieved entries? Hope someone can help.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    why do you need multiple pages if every page is going to show all records? Wouldn't you just need a single page?

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clarification

    I'd like to retrieve more than the last 10 entries from my database and display them all.


  •  

    Posting Permissions

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