Re: Question about PHP Arrays syntax

From: Date: Mon, 22 Apr 2002 06:36:41 +0000
Subject: Re: Question about PHP Arrays syntax
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-18713@lists.php.net to get a copy of this message
From: "Vania Smrkovski" <smrkovski@comcast.net> > host with PHP and MySQL support. > > a) How would you change the following the automatically find the tables and > run through the iteration. You should rtfm as php/mysql makes a lot of the torturous VB/MS/Access methods very simple. All the functions below are straight from the book. <?php $colordb = "#3333aa"; $colortbl = "#33aa33"; $link = mysql_connect ("host", "user", "password") or die ("Could not connect"); print ("Connected successfully<br>"); print ("List of all <b><font color='$colordb'>databases</font></b>/<font color='$colortbl'><b>tables</b></font>/<b>fields</b> on server<br>"); $dbResult = mysql_list_dbs($link); while($this_db = mysql_fetch_row($dbResult)) { print("&nbsp;<font color='$colordb'><b>".$this_db[0]."</b></font><br>"); $tblResult = mysql_list_tables ("$this_db[0]"); $i = 0; while ($i < mysql_num_rows ($tblResult)) { $this_tbl[$i] = mysql_tablename ($tblResult, $i); echo "&nbsp;&nbsp;<font color='$colortbl'><b>".$this_tbl[$i] . "</b></font>"; $fld_Result = mysql_list_fields("$this_db[0]", "$this_tbl[$i]", $link); $nflds = mysql_num_fields($fld_Result); echo "&nbsp;(".$nflds.")<br>"; print("<div align='left'><TABLE>\n"); for($j = 0; $j < $nflds; $j++) { print("<TR> <TD>&nbsp;<b>" . mysql_field_name($fld_Result, $j) . "</b></TD> <TD>" . mysql_field_type($fld_Result, $j) . "</TD> <TD>" . mysql_field_len($fld_Result, $j) . "</TD> <TD>" . mysql_field_flags($fld_Result, $j) . "</TD> </TR>\n"); } print("</TABLE></div>\n"); $i++; } } mysql_close ($link); ?>

« previous php.db (#18713) next »