我正在運行下面的代碼,但無法讓if語句正常工作。我希望能夠刪除div如果沒有內容,如果有,然後顯示它,但目前它要麼全部刪除它,如果一個數據庫條目是空的,而不是隻刪除1空行。如果雄蕊對數據庫查詢不起作用
<?php
$con = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
extract($_GET);
{ $result = mysqli_query($con,"SELECT * FROM links ORDER by id ");
while($row = mysqli_fetch_array($result)) {
if ($section=""){
echo"";
}
elseif ($section="a"){
echo"<div class=\"page-header\">" . $row['section'] . "\</div>";
}
echo "<div class=\"links-wrap\">
<div class=\"links-box\">
<div class=\"links-image\"><img src=\"images/links/" . $row['img1'] . "\"></div>
<div class=\"links-site-txt\">" . $row['link1'] . "</div>
<div class=\"links-desc\">" . $row['desc1'] . "</div>
</div>
<div class=\"spacer-left\"></div>
<div class=\"links-box\"></div>
<div class=\"spacer-left\"></div>
<div class=\"links-box\"></div>
</div>";}}
mysqli_close($con);
?>
你在哪裏設置'$ section'? – Aquillo 2014-09-27 14:29:10