Re: A better way of displaying query

From: Date: Wed, 02 Aug 2000 04:31:13 +0000
Subject: Re: A better way of displaying query
Groups: php.general 
Request: Send a blank email to php-general+get-9623@lists.php.net to get a copy of this message
>Mike Tuller wrote: >> >> I'm following an example in PHP essentials that shows how to display mysql >> database info in a HTML table. What I need to display is a mysql table that >> has over 20 columns and I want to know an easier way. Here is an example of >> what I have. Mike; here is a little utility script that I use to dump a table of unknown dimensions into an HTML table. Only one of the 10 or 30 flavours which Julie mentioned. HtH, Erik <? // $userID and $conn_id are defined and // established in a common include file // used by many scripts include ('../include/db.inc' ); $res_table = mysql_list_tables( $userID, $conn_id ); $num_tables = mysql_num_rows( $res_table ); while( $table_this = mysql_fetch_row( $res_table )) { print( "\n<P>" . $table_this[0] ); $sql = "SELECT * FROM " . $table_this[0]; $res = mysql_query( $sql, $conn_id ); print( "<TABLE BORDER='1' BORDERCOLOR='#bababa'>\n" ); print( "<TR BGCOLOR='#e5e5e5'>" ); $flds = mysql_num_fields( $res ); for($idx=0;$idx<$flds;$idx++) { print( "<TH>" ); print(mysql_field_name($res,$idx)); print( "</TH>" ); } print( "</TR>\n" ); while( $thisrow = mysql_fetch_row( $res )) { print( "<TR>" ); while( list( $key, $val ) = each( $thisrow )) { print( "<TD>" ); if(isset($val) && $val <>'') print( $val ); else print( "&nbsp;" ); print( "</TD>" ); } print( "</TR>\n" ); } print( "</TABLE>\n" ); } ?> ================================================================Internet service provided by telus.net http://www.telus.net/

« previous php.general (#9623) next »