Results 1 to 5 of 5

Thread: paging with for loop

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    paging with for loop

    I think I almost figured it out:
    PHP Code:
    /*
    $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 ) * $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!
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: paging with for loop

    I am confused. Are you asking a question, or are you posting this code for others to use?
    My usual boring signature: Something

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: paging with for loop

    Have a look in the PHP FAQ for a pagination example.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: paging with for loop

    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:
    PHP Code:
    if($_GET['page']==''){
        
    $url_page 1;
        }else{
        
    $url_page $_GET['page'];
        } 
    Compare bible texts (and other tools):
    TheWheelofGod

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: paging with for loop

    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']
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width