Web Design and Web Development Forum

  1. #1
    HombreRana's Avatar
    Join Date
    Oct 2004
    Location
    Cleveland, OHIO
    Age
    22
    Posts
    50
    Rep Power
    8
  2. HombreRana is on a distinguished road
  3. Page numbering (MySQL & PHP)

    OK, I have a display page which I want to use to show all entries in my database. The proble is, there are several hundred entried so far and getting bigger every day. I have them to display 30 at a time:

    PHP Code:
    $dbh=mysql_connect ("localhost""""") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db (""); 

    if(!isset(
    $start)) $start 0;

    $query="SELECT * FROM CD ORDER BY groupname, album ASC LIMIT " .$start", 30";

    $result=mysql_query($query); 
    then later, at the bottom of the page, I have:

    PHP Code:
    $query "SELECT count(*) as count FROM CD"
    $result mysql_query($query);
    $row mysql_fetch_array($result);
    $numrows $row['count'];
    if(
    $start 0
       echo 
    "<a href=\"" $PHP_SELF "?start=" . ($start 30) . 
            
    "\"><- Previous</a>\n";
    if(
    $numrows > ($start 30)) 
       echo 
    "<a href=\"" $PHP_SELF "?start=" . ($start 30) . 
            
    "\">Next -></a><BR>\n"
    Question is...how do I find the total, then list page 1,2,3,4,5,etc. so one can jump ahead quickly rather than incrementally by 30? Does this make sense?
    Reply With Quote Reply With Quote
  4. #2
    HombreRana's Avatar
    Join Date
    Oct 2004
    Location
    Cleveland, OHIO
    Age
    22
    Posts
    50
    Rep Power
    8
  5. HombreRana is on a distinguished road
  6. Re: Page numbering (MySQL & PHP)

    Nevermind...found a solution.
    Reply With Quote Reply With Quote
  7. #3
    Join Date
    Dec 2004
    Posts
    562
    Rep Power
    8
  8. eddmun is on a distinguished road
  9. Re: Page numbering (MySQL & PHP)

    share how you did it then!!!!
    Reply With Quote Reply With Quote
  10. #4
    omanofmysteryp's Avatar
    Join Date
    Sep 2004
    Posts
    386
    Rep Power
    8
  11. omanofmysteryp is on a distinguished road
  12. Re: Page numbering (MySQL & PHP)

    you can query for all records and do mysql_total_rows or mysql_num_rows or watever it was and do the math to calculate what page you were / are on:)
    Reply With Quote Reply With Quote

Similar Threads

  1. PHP Tutorial for beginners
    By YoungCoder in forum PHP Articles
    Replies: 19
    Last Post: 04-23-2006, 02:31 PM
  2. PHP MySQL Tutorial
    By Vio-Bear in forum PHP Articles
    Replies: 3
    Last Post: 02-21-2006, 09:55 PM
  3. What is PHP?
    By wizard in forum PHP Articles
    Replies: 4
    Last Post: 11-27-2005, 06:38 AM
  4. Php Syntax
    By wizard in forum PHP Articles
    Replies: 1
    Last Post: 10-06-2005, 01:53 AM
  5. PHP Tutorial - Connecting to MySQL
    By YoungCoder in forum PHP Articles
    Replies: 2
    Last Post: 09-03-2004, 05:53 AM