sql查询未在本地主机上执行

时间:2017-04-11 00:51:34

标签: php mysql sql phpmyadmin

以下是文件' 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>

1 个答案:

答案 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>";