0

I have used a simple pagination. I display 5 table values per page. When I have more values there appears more pages on the screen.

My paging output is as follows:

PREVIOUS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 NEXT

In case I have 100 pages the no goes on till 100. how can I have only 10 pages at a time using another button before NEXT? I want my output like this:

PREVIOUS 1 2 3 4 5 6 7 8 9 10 >> NEXT

this is my code:

      $perpage=ceil($match/$limit);
        if($ids!=$perpage)
        {
            echo "<a href='?ids=".($ids+1).&status=".$status."&source_type=".$source_type."&yeardropdown1=".$yeardropdown1."' id='button1'>NEXT</a>";
        }
        if($perpage>10)
        {
                    echo "<a href='?ids=".($ids+10).&status=".$status."&source_type=".$source_type."&yeardropdown1=".$yeardropdown1."' id='button1'>>></a>";
        }
        echo "<ul id='page'>";
        for($i=1;$i<=$perpage;$i++)
        {
            if($i==$ids) { echo "<li id='current'>".$i."</li>"; }
            else { echo "<li><a href='?ids=".$i.".&status=".$status."&source_type=".$source_type."&yeardropdown1=".$yeardropdown1."'>".$i."</a></li>"; }
        }
        echo "</ul>";
        if($ids>1)
        {
            echo "<a href='?ids=".($ids-1)."&status=".$status."&source_type=".$source_type."&yeardropdown1=".$yeardropdown1."' id='button'>PREVIOUS</a>";
        }

Where match is total no of records found from sql query and limit is 5 and $ids is initially 1.

Please help me

Lilly Shk
  • 147
  • 1
  • 21

0 Answers0