以下是文件' Column_details.php'中包含的一段代码。目标是在用户单击表名时显示表的所有属性。表名以$ id检索。问题是此查询在phpmyadmin上成功运行。但是当在localhost上执行Column_details.php时不会运行。
$id = $_GET['id'];
echo $id;
$result = mysqli_query($conn, "show fields from '$id'");
$row = mysqli_num_rows($result);
if($row<=0){
echo " No such columns";
}
else{
echo "<table border='1'>";
while($row=mysqli_fetch_array($result)){
$col_name = $row['Field'];
$click = "<a href='Column_details.php?mv= ".$col_name."'>" . "</a>";
echo "<tr>";
echo "<td>" . $col_name . "</td>";
echo "<td>" . $click . "</td>";
}
echo "</table>";
}
$conn->close();
?>
</body>
</html>
答案 0 :(得分:0)
在整理连接后,您可能需要修复表格
echo "<table border='1'>";
while($row=mysqli_fetch_array($result)){
$col_name = $row['Field'];
$click = "<a href='Column_details.php?mv= ".$col_name."'>" .$col_name. "</a>";
echo "<tr>";
echo "<td>" . $col_name . "</td>";
echo "<td>" . $click . "</td>";
}
echo "</table>";