$page = $_REQUEST['page'];
$query = $_POST['query'];
// check to see if $page is set
if (!$page) {
$page = 1;
}
// Change $query to a request super global after the first page.
if($page > 1){
$query = $_REQUEST['query'];
}
//set up some limits
$limit = $page * 10;
$limit = $limit - 10;
//get the count from the database table
$sql_num = mysql_query("SELECT * FROM table WHERE column LIKE %query%");
$num = mysql_num_rows($sql_num);
// query your database for the final results
$sql_results = mysql_query("SELECT something FROM table WHERE column LIKE %query% LIMIT $limit,10");
if($num < 10){
$through = $num;
} else {
$through = $limit + 10;
}
if ($through > $num){
$through = $total;
}
if($page > 1){
$from = $limit +1;
} else {
$from = $limit;
}
if($from == 0){
$from = $from +1;
}
echo "Search Results
";
echo "
"; if ($page > 1) { echo "Previous "; } if (($num > 10) && (($limit + 10) < $num)) { echo "Next"; } // Build the list from the $sql query above and display results while(list($results)=mysql_fetch_array($sql_results)){ echo "Results: $results"; } if ($page > 1) { echo "Previous "; } if (($num > 10) && (($limit + 10) < $num)) { echo "Next"; } ?>