Re: generate xls file on fly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 8, 2008 8:41 AM, Hiep Nguyen <hiep@xxxxxxxxxx> 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); } ?>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux