Forum Moderators: coopster

Message Too Old, No Replies

paging help

         

hotaru

6:50 pm on Aug 25, 2005 (gmt 0)

10+ Year Member



i need a little help with this paging script, I'm a beginner at PHP so I don't really get what I'm doing wrong >_<

=======================================
<?php
include("config.php");?>
<?
// get the pager input values
$page = $_GET['page'];
$limit = 12;
$result = mysql_query("select count(*) from $table_link");
$total = mysql_result($result, 0, 0);?>
<?

// use pager values to fetch data
$query = "SELECT * FROM $table_link ORDER BY name DESC()LIMIT $offset, $limit";
$result = mysql_query($query);
$i=0;
$i2=$i+1;
while ($i < $num) {
$image=mysql_result($result,$i,"image");
$name=mysql_result($result,$i,"name");
?>

<img border="0" src="<?=$base_url?><?=image?>" alt="<?=$name?>"></a>
<?
++$i;
}?>
<? // output paging system (could also do it before we output the page content)
if ($page == 1) // this is the first page - there is no previous page
echo "Previous";
else // not the first page, link to the previous page
echo "<a href=\"page.php?page=" . ($page - 1) . "\">Previous</a>";

for ($i = 1; $i <= $pager->numPages; $i++) {
echo " ¦ ";
if ($i == $pager->page)
echo "Page $i";
else
echo "<a href=\"page.php?page=$i\">Page $i</a>";
}

if ($page == $pager->numPages) // this is the last page - there is no next page
echo "Next";
else // not the last page, link to the next page
echo "<a href=\"page.php?page=" . ($page + 1) . "\">Next</a>";
?>

ChadSEO

10:50 pm on Aug 25, 2005 (gmt 0)

10+ Year Member



hotaru,

It would be helpful to know what is going wrong with your page. Are you getting an error message? Is there no output? Is there bad output?

For instance, you use $offset before setting it, but you might have just not included that code snippet. Any more details on what exactly is going wrong, and I'm sure someone will be able to help.

Chad

hotaru

3:44 am on Aug 26, 2005 (gmt 0)

10+ Year Member



i'm so forgetful at times >__<

i'm getting no output with the script, that would be the error. Sorry I didn't mention it before!

omoutop

6:05 am on Aug 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi!

This is what u want my friend...

[webmasterworld.com...]

Hope it helps....