check out this thread or search google for "php pagination"
i started doing this this morning and have currently like 75 pages with another 4 that i have to add. so far i have 42 pages of it in a db. and i use the pagelinks. i wanna condense the number of links to maybe 10 with ... in between.
like maybe Pages: 1 2 3 4 5 ... 38 39 40 41 42 or whatever corresponds to the last pages
kinda like this
http://neonsonline.com/pagelinks.jpg
below is the actual page and the code i use
http://www.neonsonline.com/gallery.php
this is the code i use for the pagelinks
PHP Code:
echo "<center><table width=\"75%\" cellpadding=\"5\" cellspacing=\"0\" class=\"main\">
<tr><td width=\"25%\" valign=\"top\">";
if ($page != "1") {
$prevpage = $page - 1;
echo "<a href=\"{$PHP_SELF}?page=$prevpage\">Prev. Page</a>";
}
echo "</td><td width=\"50%\" valign=\"top\" align=\"center\">
Pages: ";
$pagelink = "1";
do {
if ($page == "$pagelink") {
echo "$pagelink ";
} else {
echo "<a href=\"{$PHP_SELF}?page=$pagelink\">$pagelink</a> ";
}
$pagelink = $pagelink + 1;
} while ($pagelink <= $num_pages);
echo "</td><td width=\"25%\" valign=\"top\" align=\"right\">";
if ($page != "$num_pages") {
$nextpage = $page + 1;
echo "<a href=\"{$PHP_SELF}?page=$nextpage\">Next Page</a>";
}
echo "</td></tr></table></center>";
Last edited by ducktape; April 6th, 2003 at 14:03.
I'm back after 2 years and 3 months.
check out this thread or search google for "php pagination"
w3rd
thanks for the link none of it helped though im off to google
i already have the pages listed i just wanna make the length a bit shorter there is currently 67 pages...lol
http://www.neonsonline.com/gallery.php?page=3
I'm back after 2 years and 3 months.
You code messy
Mabe something like this?
PHP Code:<?php
// Config //////////////////////////////////////
$pages_at_front = 5;
$pages_frontback_sep = "...";
$pages_at_back = 5;
////////////////////////////////////////////////
echo "<center><table width=\"75%\" cellpadding=\"5\" cellspacing=\"0\" class=\"main\"><tr><td width=\"25%\" valign=\"top\">";
if ($page != "1") {
$prevpage = $page - 1;
echo "<a href=\"{$PHP_SELF}?page=$prevpage\">Prev. Page</a>";
}
echo "</td><td width=\"50%\" valign=\"top\" align=\"center\">Pages: ";
$pagelink = 1;
$printed_sep = 0;
do {
if($pagelink <= $pages_at_front) {
if ($page == "$pagelink") {
echo "$pagelink ";
}
else {
echo "<a href=\"{$PHP_SELF}?page=$pagelink\">$pagelink</a> ";
}
}
elseif($pagelink >= ($num_pages - $pages_at_back)) {
if($printed_sep == 0) {
echo $pages_frontback_sep;
$printed_sep == 1
}
if ($page == "$pagelink") {
echo "$pagelink ";
}
else {
echo "<a href=\"{$PHP_SELF}?page=$pagelink\">$pagelink</a> ";
}
}
$pagelink = $pagelink + 1;
} while ($pagelink <= $num_pages);
echo "</td><td width=\"25%\" valign=\"top\" align=\"right\">";
if ($page != "$num_pages") {
$nextpage = $page + 1;
echo "<a href=\"{$PHP_SELF}?page=$nextpage\">Next Page</a>";
}
echo "</td></tr></table></center>";
?>
Last edited by Cagez; April 8th, 2003 at 06:54.
i just tried that it looks cool but gives me this
http://www.neonsonline.com/gallery2.php
I'm back after 2 years and 3 months.
Oop, the elseif is supposed to say $num_pages not num_page. Try it now.
alright i just changed the code and get
PHP Code:Parse error: parse error in /home/virtual/site3/fst/var/www/html/gallery2.php on line 135
I'm back after 2 years and 3 months.
dunno, but try this, it seems to work on my server:
PHP Code:<?php
// Config //////////////////////////////////////
$pages_at_front = 5;
$pages_frontback_sep = "...";
$pages_at_back = 5;
////////////////////////////////////////////////
echo "<center><table width='75%' cellpadding='5' cellspacing='0' class='main'><tr><td width='25%' valign='top'>";
if ($page != "1") {
$prevpage = $page - 1;
echo "<a href='{$PHP_SELF}?page=$prevpage'>Prev. Page</a>";
}
echo "</td><td width='50%' valign='top' align='center'>Pages: ";
$pagelink = 1;
$printed_sep = 0;
do {
if($pagelink <= $pages_at_front) {
if ($page = $pagelink) {
echo $pagelink . " ";
}
else {
echo "<a href='{$PHP_SELF}?page=$pagelink'>" . $pagelink . "</a> ";
}
}
elseif($pagelink >= ($num_pages - $pages_at_back)) {
if($printed_sep = 0) {
echo $pages_frontback_sep;
$printed_sep = 1;
}
elseif ($page == $pagelink) {
echo $pagelink . " ";
}
else {
echo "<a href='{$PHP_SELF}?page=$pagelink'>" . $pagelink . "</a> ";
}
}
$pagelink = $pagelink + 1;
} while ($pagelink <= $num_pages);
echo "</td><td width='25%'valign='top' align='right'>";
if ($page != $num_pages) {
$nextpage = $page + 1;
echo "<a href='{$PHP_SELF}?page=$nextpage'>Next Page</a>";
}
echo "</td></tr></table></center>";
?>
Your man, DaWizman
alright works now i dunno what i did but it wasnt working at first.
thanks for the help really appreciate it
I'm back after 2 years and 3 months.
no problem
Your man, DaWizman
Its pretty messy but if it does the job, then hey![]()
i kinda gave up on this for a while but
http://www.neonsonline.com/gallery2.php
if you notice there are no ... but there are 6 numbers at the end and the first 5 numbers arent links but the last 6 numbers are
and is there a way for it to show what page its on?maybe show up like this say if there were 70 pages and i was on 35
1 2 3 ... 34 35 36 ... 68 69 70
where the 35 would actually move where the person was at or
maybe said something like page 35 of 70. and then show 1 page on each side of the actual page as in if i were on 17 the middle portion would read like 16 17 18
or what would be even better is a drop down list. that lists like
Page 1 (1-15)
Page 2 (16-30)
....
Thats what we had before i put it all in a database
Last edited by ducktape; May 1st, 2003 at 01:08.
I'm back after 2 years and 3 months.
Bookmarks