如果两个不同的表中的两行都匹配,我试图产生结果,但我很难尝试使它工作。有人可以告诉我,如果我遗失了什么......提前谢谢你
**注意:我的连接位于包含文件中,两个表都在同一个数据库中
<html>
<p>Pending Documents</p>
<?php
$sql ="SELECT * FROM `forms`";
if ($_SESSION['user_name'] == $row["username"]){ ?>
<p><a href="">SUTA Document</a></p>
<? }else { ?>
<p>No Pending Documents</p>
<? } ?>
</html>
答案 0 :(得分:0)
你应该用mysqli来解决它。这是一个工作片段:
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . mysqli->connect_error;
}
if ($result = $mysqli->query("SELECT * FROM `forms`")) {
while ($obj = $result->fetch_object()) {
if ($_SESSION['user_name'] == $obj->username){ ?>
<p><a href="">SUTA Document</a></p>
<? }else { ?>
<p>No Pending Documents</p>
<? }
}
$result->close();
}
$mysqli->close();
?>