我需要创建一个只显示数据库信息的div,如何将div连接到mysql以便它只显示我的数据库信息?
答案 0 :(得分:1)
我不确定我是否理解你的问题......但我会尝试一下。下面的代码将从数据库中选择您告诉它的任何内容并将其回显到表中。
<?php
$db = mysqli_connect('host', 'username', 'password', 'database');
$sql = "SELECT * FROM database"
mysqli_stmt_bind_param($db, "params here", your info here);
$res = mysqli_stmt_execute($sql);
mysqli_stmt_close($sql);
mysqli_close($db);
echo "<table>";
while($row = mysqli_fetch_array($res)){ //Creates a loop to loop through results
echo "<tr><td>" . $row[''] . "</td><td>" . $row[''] . "</td></tr>"; //$row['index'] the index here is a field name
}
echo "</table>";
?>