problem with paging code,php

hi expert,i have paging code here but its not working anyone can help me..
paging.php
agilentwaxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

john-formbyCommented:
On line 115, you have missed the semi-colon.  This line:

$showeachside = 5

should be:

$showeachside = 5;

Hope this helps,

John
0
agilentwaxAuthor Commented:
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
0
mike_nguyenCommented:
I think when you determines how many pages you will need to render by running the simple calculation like

$numberofpage = ceil($totalrecords / $perpage);

Then, in your paging code, take the variable that determines your current page id + number of page you want to show, then run the query

for example:

$numberofpagetoshow  = $currentid + 10;
for ($i = $currentid; $i <= $numberofpagetoshow; $i++) {
      echo "<a href='#' ...>";
}

I hope this helps.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

agilentwaxAuthor Commented:
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..

<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&region=$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&region=$region&country=$country&city=$city&start=".max(0,$start+$limit));?>">NEXT</a> 
<?php
}
?>
</td>
</tr>
<tr><td colspan="3" align="center" valign="middle">&nbsp;</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)))
    {
?>
&nbsp;<a class="<?php print($class);?>" href="<?php print("$thispage".($y>0?("?option=com_content&view=article&id=156&find=$find&region=$region&country=$country&city=$city&start=").$y:""));?>"><?php print($pg);?></a>&nbsp; 
<?php
    }
    $pg++;
}
if(($start+$eitherside)<$nume)print (" .... ");
?>
</td>

Open in new window

0
agilentwaxAuthor Commented:
sori mike nguyen,,ignore my previous question..i have solve the problem
0
mike_nguyenCommented:
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">&nbsp;</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>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.