如果php中的属性等于1,则隐藏div

用户单击查看详细信息后,我将显示特定属性的属性详细信息。如果属性类型值为 Open Plots,那么我不想显示停车场 div。我为此编写了代码,但出现意外错误 '< '


这是我写的代码:


<?php session_start();

include 'db.php';   

$id = (int)$_GET['id'];

$sql = "SELECT * FROM tbl_properties WHERE property_id = $id";

$oppointArr =array();

$result = mysqli_query($conn,$sql);

if (mysqli_num_rows($result) > 0) 

{

  while($row = mysqli_fetch_array($result)) 

  {          

    $oppointArr = $row;           

  }

}

else 

{

  echo "0 results";

}

?>


        <input  type='hidden' value='<?=$id;?>' name='property_id'>

    <div class="property-specs">

                            <ul class="specs-list">

                                <li><div class="icon"><span class="flaticon-double-king-size-bed"></span></div> <?php echo $oppointArr['property_type'];?></li>

                                <li><div class="icon"><span class="flaticon-copy"></span></div> <?php echo $oppointArr['area_sqft'];?> Sqft</li>

                                <li><div class="icon"><span class="fa fa-compass"></span></div> <?php echo $oppointArr['facing'];?> Facing</li>

                                <li id="car_parking"><div class="icon"><span class="flaticon-private-garage"></span></div>

                                <?php if((<?php echo $oppointArr['property_type'];?>)=='Open-Plots')

                                {

                                    <?php echo 'style="display:none;"';?>

                                }

                                else{

                                <?php echo $oppointArr['car_parking'];?>

                                }

                                </li>

                                <li id="total_bathrooms"><div class="icon"><span class="flaticon-vintage-bathtub"></span></div> <?php echo $oppointArr['total_bathrooms'];?> Bathrooms</li>

                            </ul>

                        </div>


梦里花落0921
浏览 160回答 2
2回答

元芳怎么了

使用以下内容更改您的代码条件。<?php session_start();include 'db.php';&nbsp; &nbsp;$id = (int)$_GET['id'];$sql = "SELECT * FROM tbl_properties WHERE property_id = $id";$oppointArr =array();$result = mysqli_query($conn,$sql);if (mysqli_num_rows($result) > 0)&nbsp;{&nbsp; while($row = mysqli_fetch_array($result))&nbsp;&nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; $oppointArr = $row;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; }}else&nbsp;{&nbsp; echo "0 results";}$display = 'block';if(($oppointArr['property_type'])=='Open-Plots'){&nbsp; &nbsp; $display = 'none';}?><input&nbsp; type='hidden' value='<?=$id;?>' name='property_id'><div class="property-specs">&nbsp; &nbsp; <ul class="specs-list">&nbsp; &nbsp; &nbsp; &nbsp; <li><div class="icon"><span class="flaticon-double-king-size-bed"></span></div> <?php echo $oppointArr['property_type'];?></li>&nbsp; &nbsp; &nbsp; &nbsp; <li><div class="icon"><span class="flaticon-copy"></span></div> <?php echo $oppointArr['area_sqft'];?> Sqft</li>&nbsp; &nbsp; &nbsp; &nbsp; <li><div class="icon"><span class="fa fa-compass"></span></div> <?php echo $oppointArr['facing'];?> Facing</li>&nbsp; &nbsp; &nbsp; &nbsp; <li id="car_parking" style="display:<?php echo $display?>">><div class="icon"><span class="flaticon-private-garage"><?php echo $oppointArr['car_parking'];?></span></div></li>&nbsp; &nbsp; &nbsp; &nbsp; <li id="total_bathrooms"><div class="icon"><span class="flaticon-vintage-bathtub"></span></div> <?php echo $oppointArr['total_bathrooms'];?> Bathrooms</li>&nbsp; &nbsp; </ul></div>

有只小跳蛙

<?php&nbsp;&nbsp; if($oppointArr['property_type']=='Open-Plots'){&nbsp; &nbsp; &nbsp;echo 'style="display:none;"';&nbsp; }else{&nbsp; &nbsp; &nbsp;echo $oppointArr['car_parking'];&nbsp; }?>这种方式更好吗?
打开App,查看更多内容
随时随地看视频慕课网APP