TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack (1) Thread Tools Search this Thread Display Modes
Old 09-24-2007, 11:33 PM   1 links from elsewhere to this Post. Click to view. #1 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default How to paginate the fetched data from the database?

How to paginate the fetched data (10 rows per page) from mysql_fetch_array?
Haris is offline  
Reply With Quote
Old 09-24-2007, 11:56 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Pagination really deserves a whole new tutorial, but I've written this basic one out for you to direct you down the right path. As you can see, I've hard-coded both the array and the $iCount variable, but these will be made up of two MySQL calls in your case:
  • SELECT COUNT(*) FROM myTable
  • SELECT myColumn1, myColumn2 from myTable.

Respectively.

PHP Code:
aPages = array('Pear''Orange''Grape''Kiwi''Mango''Red Pitaya''Melon''Lime''Lemon''Banana''Apple');
$iCount count($aPages);
$iPerPage 5;
$iCurPage = isset($_GET['page']) ? $_GET['page'] : 0;

$iUpper $iCurPage $iPerPage;

for(
$iIndex $iCurPage$iIndex $iUpper$iIndex++)
{
    if(!isset(
$aPages[$iIndex]))
    {
        break;
    }
    
    echo 
'Page: ' $aPages[$iIndex] . '<br />';
}

if(
$iCurPage >= $iPerPage)
{
    
$iPreviousPage $iCurPage $iPerPage;
    echo 
'<a href="pag.php?page=' $iPreviousPage '">Previous</a> ';
}

if(
$iCount $iCurPage $iPerPage)
{
    
$iNextPage $iCurPage $iPerPage;
    echo 
' <a href="pag.php?page=' $iNextPage '">Next</a>';

__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 11-26-2007, 10:43 AM   #3 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

Looking forward to a detailed pagination tutorial.

I have always seemed to have some problems thinking in the right direction regarding these things ;)

/EyeDentifty
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
Old 11-26-2007, 10:38 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You are hopeful, EyeDentify :) ! I'll give you that.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 10-18-2012, 01:41 PM   #5 (permalink)
The Addict
 
Join Date: Oct 2012
Posts: 244
Thanks: 0
dashixiong is on a distinguished road
Default

Some conservatives have Coach Factory Outlet pushed that critique further, saying that Mr. Obama’s policies are too costly, often assist the wrong people Louis Vuitton Belts and could have the paradoxical effect of driving up college costs. The dispute turns not just on different Coach Factory Outlet assessments of how policies play out, but on differing philosophical views about the role of government. During Gucci Belts his time in office, Mr. Obama has sharply increased aid to low- and middle-income students, notably through the Pell Grant Coach Factory Outlet program, which grew from $14.6 billion given to 6 million students in 2008, to nearly $40 billion for Coach Factory Outlet almost 10 million students this year. His administration also made it easier to request aid, shortening the Coach Factory Online complex federal application and allowing people to transfer their financial information electronically from the Internal Coach Outlet Online Revenue Service database. But while many education experts laud his efforts, analysts of varying political Coach Outlet Online stripes have also questioned how much impact some of the president’s policies will have, noting that the prices Coach Online Outlet charged by colleges, and student borrowing, continue to climb.But behind the headlines about soaring costs, the Coach Factory Outlet Online reality is more complex and wildly uneven, because a growing number of students receive Coach Outlet Online financial aid, and only relatively high-income families pay those fast-rising sticker prices. Adjusted for Coach Factory Online inflation, the College Board calculates, the average net price changed little over the last decade at private Coach Factory Outlet schools, and rose only modestly at public ones.Defending federal spending, Arne Duncan, the secretary of Hermes Belts education, said that for more than 30 years, college prices had risen even when federal aid had not, leading him to believe Coach Factory Online there was zero correlation.
dashixiong is offline  
Reply With Quote
Old 10-22-2012, 09:42 AM   #6 (permalink)
The Addict
 
Join Date: Oct 2012
Posts: 244
Thanks: 0
dashixiong is on a distinguished road
Default Coach Outlet

You’ve relativelyCoach Outlet recently arrived in New Delhi after living in two of Asia’s other great cities,Coach Outlet Store Online Tokyo and Hong Kong, for several years. Do these cities feel like they’re part of the same continent? Yes, and no. In terms Coach Factory Onlineof infrastructure, they couldn’t be more different. Getting regularCoach Outlet power and water at my house in New Delhi is never a sure thing, even though Coach Purse Outlet OnlineI’m paying the same rent that I paid in Tokyo and almost the same electricity prices. Both Hong Kong and Tokyo are also crowded places,Coach Factory Outlet Online but both cities are incredibly well planned and efficiently run. Efficient is not a word I would use to describe my Coach Bags Outlet Onlineday-to-day life in New Delhi. On the other hand, one thing that I think Hong Kong and New Delhi have in common isCoach Handbags Outlet a shared sense of optimism — a feeling that the best is yet to come. That’s definitely not the feeling you get in Tokyo,Coach Outlet Online or in the U.S. when I go home. It’s a big part of what I find addictive about living and working in this part of the world. You feel like you’re watching the future unfold.
dashixiong is offline  
Reply With Quote
Old 11-16-2012, 11:56 AM   #7 (permalink)
The Addict
 
Join Date: Nov 2012
Posts: 331
Thanks: 0
shui1880 is on a distinguished road
Default

Need some cool and refreshing water http://www.drdreheadphones-sale.net fun this summer to beat the heat in Georgia? We have just what you are looking for! Tubing, kayaking, water slide, hot tub cabins, Dr Dre Headphones and indoor & outdoor swimming pools are waiting for you all in one spectacular location at the Coosawattee River Resort in Ellijay. Whether the excitement of dr dre beats
a monster water slide Dr Dre Beats or the relaxation of a float down the Coosawattee River, we have the way for you to soothe that sweltering summer sizzle.
shui1880 is offline  
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.talkphp.com/absolute-beginners/1221-how-paginate-fetched-data-database.html
Posted By For Type Date
Yahoo! Answers - PHP & MYSQL doubt? This thread Refback 01-05-2008 05:08 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:25 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design