From a63410b81f799d99daea634072275e3138f64239 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Mon, 22 Apr 2002 06:10:44 +0000 Subject: [PATCH] changed example and inserted section for output git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@79380 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../mysql/functions/mysql-field-type.xml | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/reference/mysql/functions/mysql-field-type.xml b/reference/mysql/functions/mysql-field-type.xml index 58de645777..c6f1b8d77a 100644 --- a/reference/mysql/functions/mysql-field-type.xml +++ b/reference/mysql/functions/mysql-field-type.xml @@ -1,5 +1,5 @@ - + @@ -27,28 +27,39 @@ "; -echo "The table has the following fields
"; -while ($i < $fields) { - $type = mysql_field_type($result, $i); - $name = mysql_field_name($result, $i); - $len = mysql_field_len($result, $i); - $flags = mysql_field_flags($result, $i); - echo $type." ".$name." ".$len." ".$flags."
"; - $i++; -} -mysql_close(); - + mysql_connect("localhost", "mysql_username", "mysql_password"); + mysql_select_db("mysql"); + $result = mysql_query("SELECT * FROM func"); + $fields = mysql_num_fields($result); + $rows = mysql_num_rows($result); + $table = mysql_field_table($result, 0); + echo "Your '".$table."' table has ".$fields." fields and ".$rows." record(s)\n"; + echo "The table has the following fields:\n"; + for ($i=0; $i < $fields; $i++) { + $type = mysql_field_type($result, $i); + $name = mysql_field_name($result, $i); + $len = mysql_field_len($result, $i); + $flags = mysql_field_flags($result, $i); + echo $type." ".$name." ".$len." ".$flags."\n"; + } + mysql_free_result($result); + mysql_close(); ?> ]]>
+ + The abouve example would produce the following output: + + + +