ckennerdale
Programmer
I am writing code to give me a next, previous and last page option on a set of databse records- prety standard.
I have these variables
$records_per_page = 10
$total_num = mysql_num_rows($SQL2);
$total_num_page = $total_num/$records_per_page;
To link to the last page in the record set I have a line like this
echo "<a href=\"$PHP_SELF?action=list_records&cur_page=$total_num_page\">Last</a>";
So far so good.
However if the total amount of records do not divide equally by the records per page, my link to the Last page goes to an odd number.
How can I check if the value is not a round number, create it into a round number and pass the value back- so that if the last page only has 4 links on it, it would still be called say page 3 instead of page 2.5?
Thanks in advance Caspar Kennerdale
Senior Media Developer
I have these variables
$records_per_page = 10
$total_num = mysql_num_rows($SQL2);
$total_num_page = $total_num/$records_per_page;
To link to the last page in the record set I have a line like this
echo "<a href=\"$PHP_SELF?action=list_records&cur_page=$total_num_page\">Last</a>";
So far so good.
However if the total amount of records do not divide equally by the records per page, my link to the Last page goes to an odd number.
How can I check if the value is not a round number, create it into a round number and pass the value back- so that if the last page only has 4 links on it, it would still be called say page 3 instead of page 2.5?
Thanks in advance Caspar Kennerdale
Senior Media Developer