试图让它发挥作用..我不理解If else声明。基本上,如果Field Photo有一个值,我希望它显示的值如果它的值为Null显然是Else Statement woudl显示。
$row = photo
$id = $_GET['id'];
$sql = "SELECT * FROM menu_category WHERE id = '$id' order by sort";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo " <h1>".$row['category_field']."</h1> ";
echo "<div class=\"itemdescription\"> ".$row['description']."</div> ";
$row = photo("*");
if ($photo = "*") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
答案 0 :(得分:0)
使用!空来检查照片是否存在,而不是*
$row = photo
$id = $_GET['id'];
$sql = "SELECT * FROM menu_category WHERE id = '$id' order by sort";
$query = mysql_query($sql);
while($row = mysql_fetch_assoc($query)) {
$photo_exist = $row['photo'];
echo " <h1>".$row['category_field']."</h1> ";
echo "<div class=\"itemdescription\"> ".$row['description']."</div> ";
if (!empty($photo_exist)) {
echo "Have a good day!";
} else {
echo "Have a good night!";
}