View Single Post
Old 02-07-2008, 02:39 PM   #9 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
The generic code I use, form an image hosting site I built
PHP Code:
//get the total count so we know what we are working with
$count_query mysql_query("SELECT COUNT(id) AS `count` FROM `images` WHERE `uploader` = '$user->id'") or die(mysql_error());
$count_arr mysql_fetch_array($count_query);
$count $count_arr["count"];

//assign the pages
$page $data->get("page");

//if page not set, set it to zero
if($page == "")
{
    
$page 0;
}
//set this to the number of items you want it to display per page
$perpage 10;

//If there are enough rows to fit on a single page, we dont need any more pages
if(mysql_num_rows($count_query) < $perpage)
{
    
$pages 0;
}
//If there are too many rows, allow for more pages
else
{
    
$pages=ceil($count $perpage);
}
//this is where the page starts in the query
$page_start $perpage $page;
//this is where the page ends
$page_end $page_start + ($perpage);

$sql mysql_query("SELECT * FROM `images` WHERE `uploader` = '$user->id' ORDER BY `date` DESC LIMIT $page_start,$perpage") or die(mysql_error()); 
What is the $data object?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote