agilentwax
asked on
problem with paging code,php
hi expert,i have paging code here but its not working anyone can help me..
paging.php
paging.php
ASKER
thnks john-formby, its correct but the result i got so long..how to limit it..i want to make like this example
http://www.web-max.ca/PHP/misc_1.php..i want to display 10 Number of items to show either side of selected page..means only display 12345678910.....next not like in the pic
when click next it will be display like this PREV ...234567891011...NEXT..i have some code here but dont know how to combine it..i have try but got error
page.png
http://www.web-max.ca/PHP/misc_1.php..i want to display 10 Number of items to show either side of selected page..means only display 12345678910.....next not like in the pic
when click next it will be display like this PREV ...234567891011...NEXT..i have some code here but dont know how to combine it..i have try but got error
page.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
dear mike nguyen thnks for ur help..i have get what i need..but i have another problem here..
let say my paging result like this
123456789...
when i click 1 it go to index page(home page) not the result page for the page 1..how to change the code that when click 1 it go to page result 1..here my code for the paging page..
let say my paging result like this
123456789...
when i click 1 it go to index page(home page) not the result page for the page 1..how to change the code that when click 1 it go to page result 1..here my code for the paging page..
<td width="99" align="center">
<?php
if(($start-$limit) >= 0)
{
$next = $start-$limit;
?>
<a href="<?php print("$thispage".($next>0?("?option=com_content&view=article&id=156&find=$find®ion=$region&country=$country&city=$city&start=").$next:""));?>">PREV</a>
<?php
}
?>
</td>
<td width="201" align="center" class="selected">
Page <?php print($cur);?> of <?php print($max_pages);?><br>
( <?php print($nume);?> records )
</td>
<td width="100" align="center" valign="middle" bgcolor="#EAEAEA">
<?php
if($start+$limit<$nume)
{
?>
<a href="<?php print("$thispage?option=com_content&view=article&id=156&find=$find®ion=$region&country=$country&city=$city&start=".max(0,$start+$limit));?>">NEXT</a>
<?php
}
?>
</td>
</tr>
<tr><td colspan="3" align="center" valign="middle"> </td></tr>
<tr>
<td colspan="3" align="center" valign="middle" class="selected">
<?php
$eitherside = ($showeachside * $limit);
if($start+1 > $eitherside)print (" .... ");
$pg=1;
for($y=0;$y<$nume;$y+=$limit)
{
$class=($y==$start)?"pageselected":"";
if(($y > ($start - $eitherside)) && ($y < ($start + $eitherside)))
{
?>
<a class="<?php print($class);?>" href="<?php print("$thispage".($y>0?("?option=com_content&view=article&id=156&find=$find®ion=$region&country=$country&city=$city&start=").$y:""));?>"><?php print($pg);?></a>
<?php
}
$pg++;
}
if(($start+$eitherside)<$nume)print (" .... ");
?>
</td>
ASKER
sori mike nguyen,,ignore my previous question..i have solve the problem
Just want to show an alternative way
<tr>
<td width="99" align="center">
<?php
if ($start != 1) { echo "Prev link with start = start - 1"; } //If the current page 1 export Prev link
//If the current page is not 1 export prev link with start = start - 1 (for the previous page)
?>
</td>
<td width="201" align="center" class="selected">
<?php
echo "Page $start of $numberOfPages";
?>
</td>
<td width="100" align="center" valign="middle" bgcolor="#EAEAEA">
<?php
if ($start != $numberOfPages) { echo "Next link with page = page + 1"; } //If current page is not the last page show the next link
?>
</td>
</tr>
<tr>
<td colspan="3" align="center" valign="middle"> </td>
</tr>
<tr>
<td colspan="3" align="center" valign="middle" class="selected">
<?php
if ($start == 1) { //if you are at page 1, then print from one to limit. Limit is the number of page you want to show. For example, you want to show 7 page at
//time then your limit is 7.
for ($i = $start; $i <= $start + $limit; $i++) {
echo "<a href='somefile.php?start=$i'>$i</a>";
}
echo "....";
}
elseif ($start == $numberOfPages) { //If at the last page, add .... and then move from 7 from last page to last page
echo "....";
for ($i = $numberOfPages - $limit; $i <= $numberOfPages; $i++) {
echo "<a href='somefile.php?start=$i'>$i</a>";
}
}
else {
echo "....";
for ($i = $start; $i <= $start + limit; $i++) { //print from current page to limit
echo "<a href='somefile.php?start=$i'>$i</a>";
}
}
?>
</td>
$showeachside = 5
should be:
$showeachside = 5;
Hope this helps,
John