ChadWick
11-30-2006, 12:41 AM
Im using the standard page script in php:
<?php
require("db.php");
db_connect();
$max_results = 2;
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
$from = (($page * $max_results) - $max_results);
$sql = mysql_query("SELECT id, uid, title, category_main, category_sub, description FROM `tutorials` LIMIT $from, $max_results") or die("MySQL Error");
while($row = mysql_fetch_array($sql))
{
echo( "<b>$row[title]</b><br>" );
echo( " submitted by $row[uid] in $row[category_main] / $row[category_sub]<br>" );
echo( "<i>$row[description]</i><br><br>" );
}
$total_results = mysql_result(mysql_query("select count(*) as Num FROM tutorials"),0);
$total_pages = ceil($total_results / $max_results);
if(($total_pages) < 2){ echo "..."; }
else{
echo "Page <b>$page</b> out of <b>$total_pages</b><br />";
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
}
db_disconnect();
?>
but what im trying to do the effect where it will display 5 page numbers at a time only the dot dot dot to the last and first two pages...
Example:
http://bin1.myphotoupload.com/pages.gif
it basicly displays the page your on then 2 pages ahead... 2 pages behind... the first 2 pages and last two pages....
Thanks
<?php
require("db.php");
db_connect();
$max_results = 2;
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
$from = (($page * $max_results) - $max_results);
$sql = mysql_query("SELECT id, uid, title, category_main, category_sub, description FROM `tutorials` LIMIT $from, $max_results") or die("MySQL Error");
while($row = mysql_fetch_array($sql))
{
echo( "<b>$row[title]</b><br>" );
echo( " submitted by $row[uid] in $row[category_main] / $row[category_sub]<br>" );
echo( "<i>$row[description]</i><br><br>" );
}
$total_results = mysql_result(mysql_query("select count(*) as Num FROM tutorials"),0);
$total_pages = ceil($total_results / $max_results);
if(($total_pages) < 2){ echo "..."; }
else{
echo "Page <b>$page</b> out of <b>$total_pages</b><br />";
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
}
db_disconnect();
?>
but what im trying to do the effect where it will display 5 page numbers at a time only the dot dot dot to the last and first two pages...
Example:
http://bin1.myphotoupload.com/pages.gif
it basicly displays the page your on then 2 pages ahead... 2 pages behind... the first 2 pages and last two pages....
Thanks