所以我已经使用post将数据从HTML表单插入到XAMPP上运行的MySQL数据库中,然后如何在表格中的另一个HTML页面上显示这些数据呢?当我尝试从localhost运行它时,它会出现一个空白页面,顶部有一行代码。我是新手,这是我的代码:我做得对吗?
d3.request("https://erudite-master-api-awsmaui.lab.expts.net/erudite/search")
.header("Content-Type", "application/x-www-form-urlencoded")
.mimeType("application/json")
.post("intent=data-quality", function (error,data){...});
答案 0 :(得分:0)
尝试以下代码并查看有关程序更改的注释
<html>
<head>
</head>
<body>
<?php
// MySQL has been deprecated so use mysqli or pdo.
$con = mysqli_connect('localhost', 'root', '', 'form_process') die("Can not connect: " . mysql_error());
$sql = "SELECT * FROM `form_submissions`";
$myData = mysqli_query($con, $sql);
echo "<table border=1>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Phone Number</th>
<th>Class interested in</th>
</tr>";
// mysqli_fetch_array should have query result in parameters
while($row = mysqli_fetch_array($myData)){
echo "<tr>";
// use proper array in this case its $row as in while condition
echo "<td>" . $row['First'] . "</td>";
echo "<td>" . $row['Last'] . "</td>";
echo "<td>" . $row['Phone'] . "</td>";
echo "<td>" . $row['Class'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close();
?>
</body>
</html>
答案 1 :(得分:0)
你应该使用mysqli或pdo,不推荐使用mysql。 mysqli类似于mysql。
mysqli代码吼叫
$con = mysqli_connect('localhost', 'root', '', 'form_process') die("Can not connect: " . mysql_error());
$sql = "SELECT * FROM `form_submissions`";
$myData = mysqli_query($con, $sql);
while($row = mysqli_fetch_array($myData)){
/// some code
}
mysqli_close();