Pagination

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Pagination

Post by kkonline »

I have created a simple pagination. Now on a page display.php i want to display all the titles as a link

currently i have

Code: Select all

while($row = mysql_fetch_array($sql)){
    // Build your formatted results here.
    echo $row['id']."<br />";
    echo $row['content']."<br />";

}
Instead i want something like <a href="<?php echo $row['id']">$row['title']</a>

so that for corresponding id i get a corresponding page.

Also i want to give a link to last page . How to know the page number of last page.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

$lastPage = ceil($numRows/$perPage);
I believe.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Post by kkonline »

scottayy wrote:

Code: Select all

$lastPage = ceil($numRows/$perPage);
I believe.
ya thanks for that quick help.

the code below gives some parsing error like Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mysite/public_html/pages.php on line 30

Code: Select all

echo "<a href="".$_SERVER['PHP_SELF']."?page=$row['id']">$row['title']</a>";
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Arrays and objects need a little help when embedded in strings:

Code: Select all

echo "<a href=\"{$_SERVER['PHP_SELF']}?page={$row['id']}\">{$row['title']}</a>";
(#10850)
Post Reply