I'm trying to get the script below to output on a page the number of rows that a user chooses.
Also, if there are any left-over rows I want to be able to specify that there are more pages.
For example, if there are two hundred rows in a table and the user chooses to display ten rows per page what I would like is for my script to display the ten rows. Then at the bottom of the page display links to the nineteen additional pages - kind of like the PHP Builder web site search page.
Below is what I'm talking about:
// Output similar to below can be seen at the
// bottom of the PHP Builder search results page
// If you click on the "2", which is a link, the script takes the user
// to Page two - Page two displays rows 11 through 20 of the table data.
// Page 3 displays rows 21 through 30, and so forth.
Pages (20): [1] 2 3 » ... Last »
// Here is the code I'm tinkering with. I can't get it to work.
// Rows per page is user input from drop-down menu- could be 10, 20, or more.
$RowsPerPage = 10;
$TableName = "Table";
$Query = "SELECT * FROM $TableName ORDER BY Reference DESC";
$Result = mysql_db_query ($db_info[dbname], $Query, $db_connection);
$Rows = 1;
while ( count($Row = mysql_fetch_array($Result)) <= $RowsPerPage ){
echo "".$Row["Reference"]."<br>\n";
$Rows++;
}
I would appreciate if anyone could get me going in the right direction.
Thanks.