Page 1 of 1

Pagination

Posted: Fri Aug 24, 2007 1:16 am
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.

Posted: Fri Aug 24, 2007 1:18 am
by s.dot

Code: Select all

$lastPage = ceil($numRows/$perPage);
I believe.

Posted: Fri Aug 24, 2007 1:29 am
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>";

Posted: Fri Aug 24, 2007 2:30 am
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>";