Ralph Freshour <ralph@primemail.com> wrote in message news:<s478lv87b57ro1q1gu6jcp4mnbnj3pl5lf@4ax.com>. ..
> I've built a query that will return more rows than I want to fit onto
> one web page - I'm using a var to hold the table row count:
>
> $php_row_count = mysql_num_rows($php_resultID);
>
> I'm planning to use a for loop to control how many rows to display on
> one web page but can I use:
>
> mysql_fetch_object($php_resultID)
>
> with a for loop?
>
> If I've fetched 80 rows for example, I want to be able to display 20
> rows per web page so I'll have 4 hot links on the bottom of each page:
>
> 1 2 3 4
>
> that I can click on to get that number's group of 20 rows
>
> Does this scheme make sense or does someone have another design scheme
> for handling multiple web page displays?
>
> Thanks...
Check out the LIMIT clause in MySQL. This enables you to construct a
SELECT statement that says "give me X rows starting from row Y" which
is equivalent to breaking down the table contents into separate
"pages". All you need to do is request a particular page number and
calculate the offset using code similar to the following:-

$numrows is obtained by doing "SELECT count(*) FROM ..."
$rows_per_page contains the page size (e.g 10 or 15 or whatever)
$pageno is the requested page number

// calculate highest possible page
$lastpage = ceil($numrows/$rows_per_page);

// build LIMIT string to append to SELECT statement
$limit_str = 'LIMIT ' .($pageno - 1) * $rows_per_page .','
..$rows_per_page;

Easy peasy lemon squeezy

Tony (is there no beginning to this man's talents) Marston
[url]http://www.tonymarston.net/[/url]