数据库目前有两个表,在前端输入1,会显示表1,输入2,显示表二,要加什么才能实现。

前端:
<!doctype html>



Document








后面:
<?php

$conn=mysqli_connect("localhost","root","root");

if($conn){
echo"";
}
else{
echo"shibai".mysqli_error($conn);
}
echo"
";

mysqli_select_db($conn,"test");

$sql="select * from h";

$result=mysqli_query($conn,$sql);

echo"

";

echo"

";

while ($data=mysqli_fetch_assoc($result)) {

echo"<tr><td>".$data['xuehao']."</td>.

<td>".$data['name']."</td>

<td>".$data['class']."</td>

</tr>";

}
echo"

xuehaonameclass
";
?>

//定义一个表名变量就可以了吧,不懂你的php语言,逻辑大概就这样,下边语法也是根据你的猜的。。。
$table_name="";
//检测数据值
if(1){
$table_name="table1";
}
else if(2){
$table_name="table2";
}

$sql="select * from "+$table_name;

如果使用表单输入的话,直接用$_GET或者$_POST接受那个表明的值,然后按一楼的思路用if做一个判断,或者用switch.....each也行。