时间:2021-07-01 10:21:17 帮助过:7人阅读
<?php //在表格中显示表的数据,常用方式 function ShowTable($table_name){ $conn=mysql_connect("localhost","root","toor"); if(!$conn){ echo "连接失败"; } mysql_select_db("test",$conn); mysql_query("set names utf8"); $sql="select * from $table_name"; $res=mysql_query($sql,$conn); $rows=mysql_affected_rows($conn);//获取行数 $colums=mysql_num_fields($res);//获取列数 echo "test数据库的"."$table_name"."表的所有用户数据如下:
"; echo "共计".$rows."行 ".$colums."列
"; echo "
$field_name | "; } echo "
---|
$row[$i] | "; } echo "