note 12005 deleted from function.mysql-connect.php by sniper

From: Date: Fri, 15 Jun 2001 00:06:26 +0000
Subject: note 12005 deleted from function.mysql-connect.php by sniper
Groups: php.notes 
Request: Send a blank email to php-notes+get-14415@lists.php.net to get a copy of this message
OK this may be useful to all, it dumps a mysql table to the screen function dumpdata() { # dumps a mysql table to the screen #=====change this as needed===================================== $dumphost="192.168.0.1"; # your host may vary $dumpuser="youruser"; # your mysql user $dumppw="yourpass"; # your mysql passwd $dumpdb="yourdb"; # your mysql database $dumptable="yourtable"; # your mysql table $query = "SELECT * FROM " . $dumptable; #======everything below here does not need to be changed========= # Connect to your MySQL database server $connect=mysql_connect ("$dumphost", "$dumpuser", "$dumppw") or die ('I cannot connect to the database.'); # Select a default database to work with <BR> mysql_select_db ("$dumpdb") or die ('The database specified in database_name must exist '); # make a query on a table in your database $query_result_handle = mysql_query ($query)or die ('The query failed!'); # make sure that we recieved some data from our query $num_of_rows = mysql_num_rows ($query_result_handle) or die ("The query: '$query' did not return any data"); $num_of_fields=mysql_num_fields($query_result_handle) or die ("Cant list fields"); print "The query: '$query' returned $num_of_rows rows of data.<BR>"; print "The query: '$query' returned $num_of_fields fields of data.<BR>"; $result = mysql_list_fields("$dumpdb","$dumptable",$connect); # use mysql_fetch_row to retrieve the print ("<table border=2>"); for ($fld=0; $fld < $num_of_fields; ++$fld) { print "<td>" ; print mysql_field_name($result, $fld); print " &nbsp;</td>"; } for ($count = 1; $row = mysql_fetch_row ($query_result_handle); ++$count) { print("<tr>"); for ($ff=0; $ff<=$num_of_fields-1; ++$ff) { print "<td>$row[$ff]&nbsp;</td>"; } print("</tr>"); } print ("</table>"); }

« previous php.notes (#14415) next »