I'm not fammiliar with internal MySQL architecture and exactly how things
work but I was wondering what is the most effcient way of spliting reports
over multiple pages. Is there a preformance difference between these two
codes, specialy if there are some complex conditions and joins that should
be done to get result.

$page=1; // this is set via GET or POST
$items_per_page=10;
$sql="SELECT COUNT(*) FROM table";
$result=mysql_query($sql)
$number_of_items=mysql_numrows($result);
$start=($page-1)*$items_per_page;
$sql="SELECT * FROM table LIMIT $start, $items_per_page";
$result=mysql_query($sql)
while ($row=mysql_fetch_assoc($result)) {
 // here goes output
}

$page=1; // this is set via GET or POST
$items_per_page=10;
$sql="SELECT * FROM table";
$result=mysql_query($sql)
$number_of_items=mysql_numrows($result);
$start=($page-1)*$items_per_page;
mysql_data_seek($result, $start);
for ($i=0; $i<$items_per_page; $i++) {
 $row=mysql_fetch_assoc($result)
 // here goes output
}

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

Reply via email to