Best way to show multiple pages reports from database
| From: | Dejan Milenkovic | Date: | Thu, 16 Oct 2003 21:57:19 +0000 |
| Subject: | Best way to show multiple pages reports from database | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-31110@lists.php.net to get a copy of this message | ||
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
}