pagination numbering pattern
Posted on
16th Feb 2014 07:03 pm by
admin
Hello,
I have following code which works great for pagination. but i have small issue now.
Now the output is coming like this
Quotemypage.php?page=2
I want it like this
Quotemypage.php/2
code-
Code: $numrows = 100;
//$numrows = $row['numrows'];
//echo "$row[numrows]";
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
echo "$maxPage";
$self = 'mypage.php';
// creating 'previous' and 'next' link
// plus 'first page' and 'last page' link
// print 'previous' link only if we're not
// on page one
$Nav="";
If($pageNum > 1) {
$Nav .= "<a class='nav' href="$self?page=" . ($pageNum-1) . " "><< Prev</a>";
}
/*For($i = 1 ; $i <= $maxPage ; $i++) {
If($i == $pageNum) {
$Nav .= "<b>$i</b>";
}Else{
$Nav .= "<a class='nav' href="$self?page=" . $i . "">$i</a>";
}
}*/
If($i == $pageNum)
{
$Nav .= "<p class='page'>1</p>";
}
Else
{
$page1=$pageNum-1;
if($page1==0){}
else
{
$Nav .= "<p class='pagination'><a href="$self?page=" . $page1. "">$page1</a></p>";
}
$Nav .= "<p class='page'>$pageNum</p>";
$page2=$pageNum+1;
if($page2<=$maxPage)
{
$Nav .= "<p class='pagination'><a href="$self?page=" . $page2. "">$page2</a></p>";
}
else{
}
}
If($pageNum < $maxPage) {
$Nav .= "<a class='nav' href="$self?page=" . ($pageNum+1) . "">Next >></a>";
}
Echo "
" . $Nav;
/* for showing all rows
$Nav="";
If($pageNum > 1) {
$Nav .= "<a class='nav' href="$self?page=" . ($pageNum-1) . " "><< Prev</a>";
}
For($i = 1 ; $i <= $maxPage ; $i++) {
If($i == $pageNum) {
$Nav .= "<b>$i</b>";
}Else{
$Nav .= "<a class='nav' href="$self?page=" . $i . "">$i</a>";
}
}
If($pageNum < $maxPage) {
$Nav .= "<a class='nav' href="$self?page=" . ($pageNum+1) . "">Next >></a>";
}
Echo "
" . $Nav;
*/
/*$Nav="";
if ($pageNum > 1)
{
$page = $pageNum - 1;
$Nav = " <a href="$self?page=$page">|Prev|</a> ";
$Nav = " <a href="$self?page=1">|<<</a> ";
//echo "$first";
}
else
{
$Nav = ' |Prev| '; // we're on page one, don't enable 'previous' link
$Nav = ' |<< '; // nor 'first page' link
}
// print 'next' link only if we're not
// on the last page
echo "$pageNum";
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$Nav = " <a href="$self?page=$page">|Next|</a> ";
$Nav = " <a href="$self?page=$maxPage">>>|</a> ";
}
else
{
$Nav = ' |Next| '; // we're on the last page, don't enable 'next' link
$Nav = ' >>| '; // nor 'last page' link
}
Echo "
" . $Nav;*/
can anyone please tell me how can i achieve that?
Thanks in advance.
No comments posted yet
Your Answer:
Login to answer
284
7
Other forums
Can't find the problem (no error message)!
OK, here's the deal. This code is really weirdly formatted (sorry!) and hard to understand, so I'm g
max function question
Hi All
Ihave a table that holds shipment numbers and dates like this
select * from
help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted de
elseif help!
OK so I'm new to the site, as well as PHP altogether (Trying my hand at managing an online RPG) and
TimeStamp Column Problem...
I'm mad at my self and thinking I'm a little retarded. It just be some one mistake I'm missing here.
Delete HTML file after loading
I have limited experience with php and its been a year or two since I've last used it. I have a sma
Contact Form Not Working When I Add Validation Codes
So I built my first working PHP "Contact Us" like form. But, I have been trying to now mak
fopen() security
As i understood the usage of fopen() for it to function correctly the Dir you write to has to be rw
Blogging s/w
heya frndz!!! i want to start a blog.... m looking for a s/w like oscommerce which is thr for e-comm
How to file_get_contents when login required?
Hello!
I am trying to read data from a page that you have to be logged into to view, I am try