我试图从我的数据库中读取并在浏览器中显示信息,但它显示一个空白页面,我该如何解决这个问题?
这是我的html表单:
这是我的php脚本:
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['submit'])){
$sql = "SELECT * FROM mydb";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "name: " . $row["name"]. " - email: " . $row["email"]. " " . $row["phone"]. "<br>";
}
} else {
echo "0 results";
}
}
$conn->close();
?>
提前谢谢