Hi,


In your mysql query, use the LIMIT keyword at or near to the end of the query.

LIMIT 1000 will limit to the first thousand records

LIMIT 2000,1000 will retrieve 1000 records, offset by 2000 records.

Cheers,

Gareth

On 17 Feb 2004, at 22:12, Shaun wrote:

Hi,

I use the following function to display any query i send to it. Some of
these queries produce 1000's of rows and produce an internal server error,
is there a way to paginate any query sent to it - say 1000 rows per page?


Thanks for your help

// query functions
function doQuery($query){
if(!($result = mysql_query(stripslashes($query)))){
echo '<br><br><div align="center">'.mysql_error().'</div>';
exit;
} else {
$num_fields = mysql_num_fields($result);
$num_rows = mysql_num_rows($result);
if ($num_fields > 0 && $num_rows > 0){
echo '
<table border="1" cellspacing="0" cellpadding="2"
bordercolor="#FFFFFF">
<tr>';
for($i = 0; $i < mysql_num_fields($result); $i++){
echo '<td bgcolor="#ffffff"
align="center"><strong>'.mysql_field_name($result, $i).'</strong></td>';
}
for($i = 0; $i < mysql_num_rows($result); $i++){
echo '<tr>';
$row_array = mysql_fetch_row($result);
for($j = 0; $j < mysql_num_fields($result); $j++){
echo '<td bgcolor="#eeeeee" align="center">'.$row_array[$j].'</td>';
}
echo '</tr>';
}
echo '</table>';
} else {
echo '<br><br><div align="center">No data in table</div>';
}
}
}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to