RE: [PHP-DB] Re: How to show next 5 results??
| From: | pedja ventor | Date: | Thu, 08 Nov 2001 02:23:15 +0000 |
| Subject: | RE: [PHP-DB] Re: How to show next 5 results?? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-14127@lists.php.net to get a copy of this message | ||
Hello,
Try this....
<?php
//---------->NOTES:
// $start_index and $index_count "come" from the "calling" page
for //this script as a hidden fields
//if You find some bugs plese kill 'em all :-)
################################################################# prev or
next
if (isset($new_start_index)) {
if( $button=="Next >>"){
$start_index=$start_index+$index_count;
}//end if
else{
$start_index=$start_index-$index_count;
}//end else
}//end if
################################################################# script
call 1st time? .... if YES
if (!isset($query_temp)){
///{{{######################################################################
####}}}////
/// PLACE FOR WRITING SOME SQL ($quert_temp)
///
///{{{######################################################################
####}}}////
$res=mysql_query($query_temp);// or error.......some error code
$num=mysql_num_rows($res);// or error...........some error code
}//end if
################################################################# script
call 1st time? .... if NO
else{ //....................... if NO
//we have query from the previous page
$query_temp=stripcslashes($query_temp);
}//end else
$end=( $start_index+$index_count< $num ? $start_index+$index_count : $num);
############################################################## no records
?.............if YES
if ($start_index<0 or $start_index>=$end){
///{{{######################################################################
####}}}////
/// PLACE FOR WRITING MESSAGE
///
///{{{######################################################################
####}}}////
}//end if
############################################################## no records
?.............if NO
else{ //end of else is on the bottom of the page
if($start_index==0){
$start_number=1;
}//end if
else{
$start_number=$start_index;
} //end else
echo "<div align=\"center\"><font face=\"Verdana, Arial,
Helvetica,
sans-serif\" size=\"4\"><B>Displaying $start_number to $end of $num
matches</B></font></div>";
$query=$query_temp." LIMIT ".$start_index.",".$index_count;
$res=mysql_query($query_temp);// or error........................
?>
?>
<HTML>
<HEAD>
<META NAME="Prev - Next Example" Content="blah">
<TITLE>results</TITLE>
</HEAD>
<BODY>
<form name="process" method="get" action="<?PHP echo $PHP_SELF
?>">
<?PHP if ($start_index<=0 ) echo "<p align=\"center\"><input
DISABLED ";
else echo "<p align= \"center\"><input " ?>type="submit"
value="<<
Previous" name="button" width="85" style="WIDTH: 93px; HEIGHT:
24px"
size=18>
<?PHP if ($end>=$num ) echo "<input DISABLED "; else echo
"<input
" ?>type="submit" value="Next >>" name="button"
width=85 style="WIDTH:
95px; HEIGHT: 24px" size=23 width="100"></P>
<input type="hidden" value="<?PHP echo $start_index; ?>"
name="start_index">
<input type="hidden" value="<?PHP echo $index_count; ?>"
name="index_count">
<input type="hidden" value="<?PHP echo $num; ?>"
name="num">
<input type="hidden" value="<?PHP echo $query_temp; ?>"
name="query_temp">
<input type="hidden" value="0" name="new_start_index">
<?php //<--------------------
for($i1=$start_index;$i1<$end;$i1++) // writing 5 or more or less
results...
{
///{{{######################################################################
####}}}////
/// PLACE FOR WRITING RESULTS
///
///{{{######################################################################
####}}}////
}
}//end else
?>
</form>
</body>
</html>
/*\----------------------------------IN C++
VERITAS -------------------------------------/*\
[ventor@teamnet.ws]