paging with for loop

Discussion in 'PHP' started by gilgalbiblewheel, Jul 16, 2008.

  1. #1
    I'm trying to figure out the formula on how to page a file:
    And when page = 1 then what is called $startpage (not to be confused with the paging of the url) would start at 1.
    And when page = 2 then what is called $startpage would be 101.
    And when page = 3 then what is called $startpage would be 201.
    $totalPages=722;
    $url_page= $_GET['page'];//grabs the page from the URL. The rest I can't figure  out if it's right.
    for($thisPage = 1; $thisPage <= $totalPages; $thisPage = $thisPage+100 ){
    	$startpage = $thisPage;
    }
    $num_pages = 100;
    PHP:

     
    gilgalbiblewheel, Jul 16, 2008 IP
  2. Rukna

    Rukna Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I couldnot understand,but u can try this,

    like this
    if(page==1)
    $startpage=what u want;
    else if(page==2)
    $startpage=what u want;
    else if(page==3)
    $startpage=what u want;


    more infor.............
     
    Rukna, Jul 16, 2008 IP
  3. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    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
    PHP:
    I tried to be as detailed as possible. If there are any more questions let me know thanks!
     
    gilgalbiblewheel, Jul 16, 2008 IP
  4. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    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'];
    	}
    PHP:
     
    gilgalbiblewheel, Jul 17, 2008 IP