Re: generate xls file on fly
| From: | Daniel Brown | Date: | Fri, 08 Feb 2008 15:02:46 +0000 |
| Subject: | Re: generate xls file on fly | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-268939@lists.php.net to get a copy of this message | ||
On Feb 8, 2008 8:41 AM, Hiep Nguyen <hiep@ee.ucr.edu> wrote:
> hi friends,
>
> i have a php page with the following logic:
>
> <html>
> <head>
> <title>Download</title>
> </head>
> <table>
> <tr><td>Title></td><td>Author</td></tr>
> <? $sql = "select title,author from book where title != null and author !=
> null"; ?>
> <? $rs = mysql_query($sql) or die(mysql_error()); ?>
> <? while($row = mysql_fetch_array($rs)) { ?>
Hiep,
You should also put all of the code you can into one block. Each
time you <? open and close ?> it will take longer to load. Not
noticeably on a single page with one user accessing it, but with full
sites and many simultaneous users, it will be noticeable. This is
because PHP is "stepping in and out" of parse mode. So simply
concatenate that code as follows:
<tr><td>Title></td><td>Author</td></tr>
<?
$sql = "select title,author from book where title != null and
author != null";
$rs = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($rs)) {
echo
"<tr><td>".$row[0]."</td><td>".$row[1];."</td></tr>\n";
}
?>
<tr><td><a href="">Download Into Excel
File</a></td></tr>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>