我想创建一个代码来检查精确列中的值是否等于'neodobren',并且列中是否有这样的值来回显“添加成员”按钮,并为每个值回显。我试图做以下事情并没有回应是: 我有以下MySQL表格内容:
UID Name Phone Email SchoolGymnasium City Password Status
1 neodobren
2 neodobren
我在HTML索引页面中有以下PHP代码:
$con = mysql_connect("localhost","****","****");
mysql_query("SET NAMES UTF8");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("***", $con);
include("../../sql.php");
session_start();
$zaqvki = mysql_query("SELECT * FROM Directors WHERE Status='neodobren' LIMIT 1");
if(mysql_num_rows($zaqvki) > 0) {
echo '<div align="right"><a href="add/director/" class="btn add-project">Add Member</a></div><br>';
// display data in table
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array($zaqvki)) { //$zaqvki was $result, before a guy comment me this...
echo "Yes";
} }
else {
echo "No";
}
它只显示按钮添加成员,而不显示是,必须回显。
答案 0 :(得分:0)
使用mysql_fetch_assoc获取关联数组并对某列的每一行进行比较:
while($row = mysql_fetch_assoc($result))
{
if($row['Status'] === 'neodobren')
echo "Yes";
else
echo "No";
}