RE: [PHP] Code Improvement

2002-06-13 Thread Lazor, Ed

Why display all 5000 records and 50 fields at once?  Typically, you display
a sub-set of the row data and page through it to improve performance.  Also,
you typically display a sub-set of fields and then view individual records
for full detail.

 -Original Message-
 From: Pong-TC [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 13, 2002 2:40 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Code Improvement
 
 
 Hello All
 
 I run the simple code to display data from the database.  
 There are around
 5000 records and 50 fields.  It takes around 1 1/2 min to retrieve the
 data to the browser.  I'd like to know if we can improve my 
 code.  So, I
 can retrieve the data in a shorter period of time.  I have codes as
 follows:
 
 $conn = (mssql_connect(20.23.252.3,hello,hello)) or die(Cannot
 connect to the database.);
 mssql_select_db(research,$conn);
 
 $strSQL = Select * from dss_student order by stuidterm;
 $rs = mssql_query($strSQL,$conn) or die(Cannot connect to 
 the table);
 
 echo table border='0' cellspace=1tr;
 echo th bgcolor='#faf0e6'font face='verdana' 
 size=2NO./font/th;
 
 while($fld = mssql_fetch_field($rs)){
   echo th bgcolor='#faf0e6'font 
 face='verdana' size=2 . $fld-name .
 /font/th;
   }
 
 echo /tr;
 
 $no_row = 1;
 while ($row = mssql_fetch_row($rs)){ 
 if (($no_row % 2) == 1) 
   echo tr;
 else 
 echo tr bgcolor='#faf0e6';
 
 echo tdfont face='verdana' size=2$no_row/font/td;
 for ($i=0;$i=49;$i++)
   echo tdfont face='verdana' size=2$row[$i]/font/td;
 $no_row++;
 }
 echo /table;
 mssql_close();
 
 POng
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.   

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




Re: [PHP] Code Improvement

2002-06-13 Thread Kevin Stone

Though your code isn't the cleanest I've seen I don't think there is
anything inherently wrong with your proceedure.  You're just displaying a
LOT of information.  And more importantly you're displaying this in a
browser with HTML tables.  I'd put a timer on your code to see how much time
the actual query took.  Then subtract that from the time it took to render
the information in the browser window and you can get a pretty good feel for
where your bottle neck is.  I susspect the query will be a small percentage
of the total time involved.

Look into the microtime() to setup the timer.  Good luck.

-Kevin

- Original Message -
From: Pong-TC [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 13, 2002 3:40 PM
Subject: [PHP] Code Improvement


 Hello All

 I run the simple code to display data from the database.  There are around
 5000 records and 50 fields.  It takes around 1 1/2 min to retrieve the
 data to the browser.  I'd like to know if we can improve my code.  So, I
 can retrieve the data in a shorter period of time.  I have codes as
 follows:

 $conn = (mssql_connect(20.23.252.3,hello,hello)) or die(Cannot
 connect to the database.);
 mssql_select_db(research,$conn);

 $strSQL = Select * from dss_student order by stuidterm;
 $rs = mssql_query($strSQL,$conn) or die(Cannot connect to the table);

 echo table border='0' cellspace=1tr;
 echo th bgcolor='#faf0e6'font face='verdana' size=2NO./font/th;

 while($fld = mssql_fetch_field($rs)){
 echo th bgcolor='#faf0e6'font face='verdana' size=2 . $fld-name .
 /font/th;
 }

 echo /tr;

 $no_row = 1;
 while ($row = mssql_fetch_row($rs)){
 if (($no_row % 2) == 1)
 echo tr;
 else
 echo tr bgcolor='#faf0e6';

 echo tdfont face='verdana' size=2$no_row/font/td;
 for ($i=0;$i=49;$i++)
 echo tdfont face='verdana' size=2$row[$i]/font/td;
 $no_row++;
 }
 echo /table;
 mssql_close();

 POng



 --
 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




Re: [PHP] Code Improvement

2002-06-13 Thread Miguel Cruz

On Thu, 13 Jun 2002, Pong-TC wrote:
 I run the simple code to display data from the database.  There are around
 5000 records and 50 fields.  It takes around 1 1/2 min to retrieve the
 data to the browser.  I'd like to know if we can improve my code.  So, I
 can retrieve the data in a shorter period of time.  I have codes as
 follows:

You're sending 250,000 table cells. That's going to take a while to 
render, no matter what.

Are you sure that the time is taken in generating the data rather than in
actually rendering the display? How long does it take when you use lynx
and dump it to /dev/null?

% time lynx -dump http://yahoo.com  /dev/null 
lynx -dump http://yahoo.com  /dev/null  0.03s user 0.01s system 11% cpu 0.352 total

miguel


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