Jim,
Your totally right, must have slipped my mind.

Brian Seymour
AeroCoreProductions
http://www.aerocore.net/

-----Original Message-----
From: Jim Lucas [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 27, 2007 1:07 AM
To: Brian Seymour
Cc: php-general@lists.php.net
Subject: Re: [PHP] Too many records to display in one web page

Brian Seymour wrote:
> Eduardo,
> The best way to do it is on both a php and sql level. Use sql's limit
> keyword in your query to return only the amount of records you want. For
> instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT
> 10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to
> iterate through all the values. If you want to have the the amount of
> records dynamically generate then either have a asdf.php?min=0&max=9 or
just
> do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways
to
> do this. However I find this one to be the most efficient.

problem with your example.

Limit is not used that way

Check out this page for further explanation

http://dev.mysql.com/doc/refman/5.0/en/select.html#id3064319


Here is something I whipped together for this as an example


<?php

$page = 1;
$rowsPerPage = 10;
$start = 0;

if (
        isset($_GET['page']) &&
        is_numeric($_GET['page']) &&
        $_GET['page'] >= $page
        ) {
        $start = ($rowsPerPage * floor($_GET['page']) );
}

$SQL = "select * from table LIMIT {$start}, {$rowsPerPage}"

display results...

?>

Let me know if I completely confused you.  I am often confusing...

Jim Lucas

> 
> Hope this helped. 
> 
> Brian Seymour
> AeroCoreProductions
> http://www.aerocore.net/
> 
> -----Original Message-----
> From: Eduardo Vizcarra [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, May 26, 2007 7:18 PM
> To: php-general@lists.php.net
> Subject: [PHP] Too many records to display in one web page
> 
> Hi All
> 
> I am developing a web site that interacts with a MySQL database. When I
run 
> a query and display the records in a web page, this can become a problem 
> because there might be too many records to be displayed in one single web 
> page so I am trying to divide the total number of records and display them

> in multiple pages. Let's say, if the query returns 100 records then I
would 
> like to display the first 10 records and then put a navigation bar where I

> can go to the next 10 or return to the previous 10 records
> 
> Is this done at a SQL or PHP level ? any experience on doing this ?
> 
> Thanks a bunch
> Eduardo 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to