标签:style class blog c code java
----- 023-dbinfo.php -----
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5 <title>MySQL数据库信息</title> 6 </head> 7 <body> 8 <h2>MySQL数据库信息</h2> 9 <pre style="font-family:微软雅黑; font-size:14pt"> 10 <?php 11 /* 12 mysql_connect() 执行连接 13 mysql_query() 执行SQL语句 14 mysql_result(资源,行,[列])查询具体数据 15 mysql_num_rows()返回行数 16 mysql_num_fields()返回列数 17 mysql_fetch_row|assoc|array 返回一行,指针后移 18 mysql_fetch_field($result, 列索引) 返回列信息 19 */ 20 21 $con = @mysql_connect("localhost", "root", "root") or die("连接失败"); 22 //$dblist = mysql_list_dbs($con);系统不推荐 23 $dblist = mysql_query("SHOW DATABASES"); 24 echo "共有数据库:", mysql_num_rows($dblist), "个。\n"; 25 while($s = mysql_fetch_row($dblist)) 26 echo $s[0], ", "; 27 echo "\n"; 28 29 mysql_query("USE world"); 30 $tblist = mysql_query("SHOW TABLES"); 31 echo "共有数据表:", mysql_num_rows($tblist), "个。\n"; 32 while($s = mysql_fetch_row($tblist)) 33 echo $s[0], " "; 34 echo "\n第三个表:", mysql_result($tblist, 2, 0), "\n"; 35 36 $result = mysql_query("SELECT * FROM COUNTRY"); 37 $s = mysql_fetch_field($result, 5); 38 echo "数据表共有", mysql_num_fields($result), "列\n"; 39 echo "第六列的字段信息:", var_export($s), "\n"; 40 echo "列长:", mysql_field_len($result, 5), "\n"; 41 echo "列名:", mysql_field_name($result, 5), "\n"; 42 echo "列数据类型:", mysql_field_type($result, 5), "\n"; 43 ?> 44 </pre> 45 </body> 46 </html>
标签:style class blog c code java
原文地址:http://www.cnblogs.com/baijifeilong/p/3750456.html