// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 20;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
include"/home/freef/public_html/otezz/friendster-skins/codes/connect_db.php";
$query="SELECT * FROM wp_links_exchange LIMIT $from, $max_results";
$command=mysql_query ($query);
while ($d=mysql_fetch_array ($command)){
?>
| Buy Modern Art Directory
|
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM wp_links_exchange"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
// Build Page Number Hyperlinks
echo "Select a Page “;
// Build Previous Link
if($page > 1){
$prev = ($page – 1);
echo “< “;
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "$i “;
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "Next>>“;
}
?>
|