@mysql_connect("localhost", "root","1981427") //选择数据库之前需要先连接数据库服务器
or die("数据库服务器连接失败");
$dbs = mysql_list_dbs(); //调用mysql_list_dbs函数
while ($array = mysql_fetch_row($dbs)) //循环输出所有的数据库名称
{
echo "$array[0]
";
}
?>
@mysql_connect("localhost", "root","1981427") //选择数据库之前需要先连接数据库服务器
or die("数据库服务器连接失败");
$dbs = mysql_list_tables("test"); //调用mysql_list_tables函数
while ($array = mysql_fetch_row($dbs)) //循环输出所有的表名称
{
echo "$array[0]
";
}
?>
mysql_connect("localhost","root","1981427"); //连接服务器
mysql_select_db("test"); //选择数据库
$result = mysql_query("SELECT * FROM tablename1"); //执行查询操作
echo mysql_num_fields($result); //获取列的数目
?>
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_name($result,0); //获取列的名称
?>
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_type($result,0); //获取列的数据类型
?>
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_len($result,0); //获取列的长度
?>
mysql_connect("localhost","root","1981427");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM tablename1");
echo mysql_field_flag($result,0); //获取列的标志
?>
mysql_connect("localhost","root","1981427"); //连接服务器
mysql_select_db("test"); //选择数据库
echo "
"; //输出表头
echo "
列名 |
类型 |
长度 |
标志 | ";
$result = mysql_query("SELECT * FROM tablename1"); //在mytable表上执行SQL语句
$fields = mysql_num_fields($result); //获得列的数目
for($i=0; $i{
//获得列的各个属性
$name = mysql_field_name($result,$i); //获得列的名称
$type = mysql_field_type($result,$i); //获得列的类型
$length = mysql_field_len($result,$i); //获得列的长度
$flags = mysql_field_flags($result,$i); //获得列的标志
echo "
$name |
$type |
$length |
$flags |
";
//输出列的信息
}
echo "
";
mysql_close(); //关闭与数据库的连接
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn