Php > Site Navigation
Page numbers
Page numbers \r\n"; echo "
\r\n"; for ($i = 0; $i <= $opt_cnt; $i ++) { if ($option[$i] == $go) { echo "
".$option[$i]."
\r\n"; } else { echo "
".$option[$i]."
\r\n"; } } echo "
\r\n"; echo "
\r\n"; echo "\r\n"; $connection = mysql_connect ($host, $user, $pass) or die ("Unable to connect"); mysql_select_db ($db) or die ("Unable to select database $db"); // control query------------------------------ /* this query checks how many records you have in your table. I created this query so we could be able to check if user is trying to append number larger than the number of records to the query string.*/ $off_sql = mysql_query ("$query") or die ("Error in query: $off_sql".mysql_error()); $off_pag = ceil (mysql_num_rows($off_sql) / $nol); //-------------------------------------------- $off = $_GET['offset']; //paranoid if (get_magic_quotes_gpc() == 0) { $off = addslashes ($off); } if (!is_numeric ($off)) { $off = 1; } // this checks if user is trying to put something stupid in query string if ($off > $off_pag) { $off = 1; } if ($off == "1") { $limit = "0, $nol"; } elseif ($off <> "") { for ($i = 0; $i <= ($off - 1) * $nol; $i ++) { $limit = "$i, $nol"; $count = $i + 1; } } // Query to extract records from database. $sql = mysql_query ("$query LIMIT $limit") or die ("Error in query: $sql".mysql_error()); while ($row = mysql_fetch_object($sql)) { // EDIT ME. Edit the line below to match your own table. Just replace $row->url with $row->your_table_column echo "$count.
url\">$row->title
\r\n"; // this is example, you may enter here anything you like $count += 1; } echo "
\r\n"; if ($off <> 1) { $prev = $off - 1; echo "[ <
prev
] \r\n"; } for ($i = 1; $i <= $off_pag; $i ++) { if ($i == $off) { echo "[
$i
] \r\n"; } else { echo "[
$i
] \r\n"; } } if ($off < $off_pag) { $next = $off + 1; echo "[
next
> ] \r\n"; } echo "
\r\n"; echo "Page $off of $off_pag
\r\n"; ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage