PDA

Click to See Complete Forum and Search --> : paging with for loop


gilgalbiblewhee
Jul 16th, 2008, 12:48 PM
I think I almost figured it out:
/*
$totalPages=722;
$url_page= $_GET['page'];
$num_pages = 100;
for($thisPage = 1; $thisPage <= $totalPages; $thisPage = $thisPage+$num_pages ){
$startpage = $thisPage;
}
*/
$num_pages = 100;//is the number of html pages inserted in a database per minute because online servers can't do all at once
$totalPages=722;//is the total amount of pages of html that exist
$end_url_page= $totalPages/$num_pages;//is LAST page of this file's url. This file will repeat every minute due to the 1 minute rule for online servers with the extension?page=1, ?page=2...
$url_page= $_GET['page'];//is PRESENT page of this file's url.
$startpage = (($url_page - 1 ) * $num_pages) + 1;//is the present html page to be inserted in the database
I tried to be as detailed as possible. If there are any more questions let me know thanks!

dclamp
Jul 17th, 2008, 01:44 AM
I am confused. Are you asking a question, or are you posting this code for others to use?

visualAd
Jul 17th, 2008, 08:52 AM
Have a look in the PHP FAQ for a pagination example.

gilgalbiblewhee
Jul 17th, 2008, 10:23 AM
How do you make it so that if the url has no ?page=1 extension then there has to be an assumption that it is 1?
This didn't work:
if($_GET['page']==''){
$url_page = 1;
}else{
$url_page = $_GET['page'];
}

visualAd
Jul 17th, 2008, 12:09 PM
You should use isset($_GET['page']) to test it instead. You should also, where present cast the variable to an integer to prevent injection attacks. $url_page = (int) $_GET['page']