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=1><tr>"; > echo "<th bgcolor='#faf0e6'><font face='verdana' > size=2>NO.</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 "<td><font face='verdana' size=2>$no_row</font></td>"; > for ($i=0;$i<=49;$i++) > echo "<td><font 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