Results 1 to 5 of 5

Thread: Creating pages dynamically

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Creating pages dynamically

    I've been trying to figure out an algorithm to create pages, dynamically.

    Like, take my website for example (BinaryIdiot.com). I get all of my news from a database. I'd like to show, let's say 15 postings at a time, per page.

    At the bottom I have a link that goes to next page but that only counts back, like 15 (can't remember if it's 15 or 14) and uses that as a start ID.

    For some reason I can't wrap my head around doing actual page numbers. How do I do this?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Creating pages dynamically

    Here's my pagination code - hopefully you can make some sense out of this

    PHP Code:
    $page = (!isset($_GET['p'])) ? : (int)$_GET['p'];
    $perPage = (!isset($_GET['pp'])) ? 10 : (int)$_GET['pp'];
    $order = (!isset($_GET['order'])) ? 'DESC' 
             (
    strtolower($_GET['order']) == 'asc' 'ASC' 'DESC');

    $lower = ($page 1) * $perPage;

    $posts $db->query(
      
    'SELECT * FROM `posts` ORDER BY `date` '.$order.' LIMIT '.$lower.', '.$perPage
    ); 
    $_GET['p'] is the page number (default 1) and $_GET['pp'] is how many posts per page (default 10).

    $_GET['order'] is ascending/descending.

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

    Re: Creating pages dynamically

    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
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Creating pages dynamically

    And on that note, I must swear that I did not copy Adam's code. :honest:

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

    Re: Creating pages dynamically

    Quote Originally Posted by penagate
    And on that note, I must swear that I did not copy Adam's code. :honest:
    Sure you didn't.




    You'll be hearing from my layer
    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