开发者

Show if an SQL Row is empty

开发者 https://www.devze.com 2023-02-07 11:21 出处:网络
I\'ve got an SQL Statement setup and a repeating region, Now with the repeating region I have an Dynamic Image. If the Database Table in question is empty, I would like to not show an image at all, or

I've got an SQL Statement setup and a repeating region, Now with the repeating region I have an Dynamic Image. If the Database Table in question is empty, I would like to not show an image at all, or maybe replace it with a blank image. What I'd like to know is how do I do this?

My code is :

mysql_select_db($database_db_connect, $db_connect);
$query_homepage_ticked = "SELECT * FROM disp_ticked";
$homepage_ticked = mysql_query($query_homepage_ticked, $db_connect) or die(mysql_error());
$row_homepage_ticked = mysql_fetch_assoc($homepage_ticked);
$totalRows_homepage_ticked = mysql_num_rows($homepage_ticked);

<?php do { ?>
      <li>
        <a href="property.php?category_id=<?php echo $row_homepage_ticked['category_id']; ?>&property_id=<?php echo $row_homepage_ticked['property_id']; ?>&image_id=<?php echo $row_homepage_ticked['image_id']; ?>">
          <img src="carousel.php?image=propertyimages/<?php echo $row_homepa开发者_如何学运维ge_ticked['image_url']; ?>" width="175px" height="130px" />
        </a>
      </li>
      <?php } while ($row_homepage_ticked = mysql_fetch_assoc($homepage_ticked)); ?>

Thanks in advance.


<?php 
if(isset($row_homepage_ticked['image_url']) 
     && !empty($row_homepage_ticked['image_url']) 
{ 
    ?>
    <img src="carousel.php?image=propertyimages/<?php echo $row_homepage_ticked['image_url']; ?>" width="175px" height="130px" />      
    <?php 
} 
?>


Try this and see...

<?php if $row_homepage_ticked['image_url']="" ?>
<img src="path_of_the_default_image" width="175px" height="130px" />

<?php else ?>
<img src="carousel.php?image=propertyimages/<?php echo $row_homepage_ticked['image_url']; ?>" width="175px" height="130px" />


foreach($row_homepage_ticked as $value)
{
if($value['image_url'] == "")
{
// then show blank image
}
else
{
//your normal code
}
}
0

精彩评论

暂无评论...
验证码 换一张
取 消