首先默认选择库test1,01.php中然后用show tables;查询出所有的表,然后用循环依次输出所有的表名,和操作超链接,超链接上对应有该表的信息传到02.php,02.php中,根据接收到的参数,查询到该表,然后用desc 表名,结果循环输出表字段名,再查询出所有字段循环输出对应的值,后面有操作超链接,存有该行数据的信息,传到03.php.03.php可以更改
01.php
<?php
$conn=mysql_connect("localhost","root","111111");
mysql_query("set names utf8",$conn);//设置编码
mysql_query("use test1");//选库
$sql="show tables";
$rs=mysql_query($sql,$conn);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>列出所有表</title>
</head>
<body>
<table border=1 width=50%>
<p>所有的表</p>
<tr>
<td>表名</td>
<td>操作</td>
</tr>
<?php
while($row=mysql_fetch_assoc($rs)){
echo "<tr>";
echo "<td>",$row["Tables_in_test1"],"</td>";
echo "<td>","<a href=02.php?table=".$row["Tables_in_test1"].">编辑</a></td>";
echo "</tr>";
}
?>
</table>
</body>
</html>
02.php
<?php
$conn=mysql_connect("localhost","root","111111");
mysql_query("set names utf8",$conn);//设置编码
mysql_query("use test1");//选库
$table=$_GET['table'];//接收数据
addslashes($table);
$sql="select * from ".$table;
$rs=mysql_query($sql,$conn);
$sql="desc ".$table;
$ziduan=mysql_query($sql,$conn);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表中所有的数据</title>
</head>
<body>
<table border=1 width="50%">
<?php
$i=0;//记录多少字段
echo "<tr>";
while($row=mysql_fetch_row($ziduan)){
echo "<td>",$row[0],"</td>";
$i++;
}
echo "<td>操作</td>";
echo "</tr>";
while($row=mysql_fetch_row($rs)){
echo "<tr>";
for($a=0;$a<$i;$a++){
echo "<td>",$row[$a],"</td>";
}
echo "<td><a href=03.php?id=".$row[0].">编辑</a></td>";
echo "</tr>";
}
?>
</table>
</body>
</html>
03.php
待定