SQL语句关联查询
<?php
//获取数据库中的所有留言
require_once("connect.php");
//执行数据库查询
$sql="select msgs.id,msgs.title,users.name,msgs.time from msgs,users where users.id = msgs.authord";
$results = mysqli_query($link,$sql);
//处理查询结果
while($row = mysqli_fetch_assoc($results)){
echo "<table border='1'>";
echo "<tr>";
echo "<td>" . $row["id"] . "</td>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>"."<a href='deleteMsg.php'>"."添加"."</a>"."<a href='deleteMsg.php'>"."删除"."</a>"."</td>";
echo "</tr>";
echo "</table>";
};
//关闭数据库连接
mysqli_close($link);
?>