在我的网站上创建一个 div 以 php 显示数据库信息

Create a div on my website that shows database information with php

我需要创建一个只显示数据库信息的 div,我应该如何将 div 连接到 mysql 以便它只显示我的数据库信息?

我不确定我是否理解您的问题...但我会试一试。下面的代码将 select 无论您从数据库中告诉它什么,并将其回显到 table.

<?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>";
?>