Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. paging in php [modified]

paging in php [modified]

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpmysql
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umeshdaiya
    wrote on last edited by
    #1

    hi, i would like to know how i can paging in php with mysql. i want next, pre , first, last and combo box(listbox) where total number of pages shows in the combo box and when i click on page number than show records.

    modified on Thursday, April 23, 2009 7:39 AM

    M R 2 Replies Last reply
    0
    • U umeshdaiya

      hi, i would like to know how i can paging in php with mysql. i want next, pre , first, last and combo box(listbox) where total number of pages shows in the combo box and when i click on page number than show records.

      modified on Thursday, April 23, 2009 7:39 AM

      M Offline
      M Offline
      Marc Firth
      wrote on last edited by
      #2

      What you are looking for is "pagination": Google[^]

      Neonlight

      1 Reply Last reply
      0
      • U umeshdaiya

        hi, i would like to know how i can paging in php with mysql. i want next, pre , first, last and combo box(listbox) where total number of pages shows in the combo box and when i click on page number than show records.

        modified on Thursday, April 23, 2009 7:39 AM

        R Offline
        R Offline
        Right Handed Monkey
        wrote on last edited by
        #3

        Basically you are going to use a technique similar to that in a previous post: http://www.codeproject.com/script/Forums/View.aspx?fid=1640&msg=1742252[^] Your sql queries will use the LIMIT keyword which specifies the number of pages a query is broken into and how many results to display. In MySQL it's like this SELECT COUNT(*) AS total_pages FROM `table01`; $result = $dbHandle->query($sql); $row = $result->fetch_assoc(); $total_rows = $row['total_pages']; //You'll need to calculate the end page, to display links to prev and next $end_page = ceil($total_rows/$span); SELECT * FROM `table01` LIMIT 0, 10; where 0 is the current page being viewed (0 indexed) and 10 is the number of elements to return ($span). in your code, the query will be: "SELECT * FROM `table01` LIMIT $cur_page, $span" and $cur_page will be a GET requested variable $cur_page = $_GET['page']; if (!$cur_page) $cur_page = 0; Now display the results of the above query. Then display the previous and next links however you like display_link("page.php?cur_page=".$cur_page--); //prev display_link("page.php?cur_page=".$cur_page++); //next You can find a nicely formatted display was found on the web: http://www.phpeasystep.com/phptu/29.html[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups