如果mysql表中的sold = 0,我需要数据具有不同的样式 当我使用下面的代码时,网站显示一个空白的白页
(?= $ vehicle->这是车辆参考 和sold是带有sql表的列
<?php
if (?=$vehicle->sold?!= 1)
{
<div class="foo">
<div class="fboverlay"></div>
<a>
<a href="/listing/<?=$vehicle->vehicle_id?>"><img src="/media.php?productId=<?=$vehicle->vehicle_id?>&file=<?=$vehicle->main_image?>" /></a>
</a>
</div>
}
else {
<a href="/listing/<?=$vehicle->vehicle_id?>"><img src="/media.php?productId=<?=$vehicle->vehicle_id?>&file=<?=$vehicle->main_image?>" /></a>
}
?>
答案 0 :(得分:0)
您需要从基础知识中学习PHP。了解运营商,PHP和HTML secion等。
无论如何,我修复了你的代码。条件是如果$vehicle->sold
不等于1.但我认为,(在您的OP中,您提到它应该为0)您想要这样:$vehicle->sold == 0
//Use sytnax like this. See php opeartors.
if ($vehicle->sold != 1) {
?> <!-- Close the php -->
<div class = "foo">
<div class = "fboverlay"></div>
<a href = "/listing/<?= $vehicle->vehicle_id ?>"><img src = "/media.php?productId=<?= $vehicle->vehicle_id ?>&file=<?= $vehicle->main_image ?>" /></a>
</div>
<?php
//Open the php again
} else {
?> <!-- close the php -->
<a href = "/listing/<?= $vehicle->vehicle_id ?>"><img src = "/media.php?productId=<?= $vehicle->vehicle_id ?>&file=<?= $vehicle->main_image ?>" /></a>
<?php //Open again
}