mysqli query for no results do something else do something else
Posted
by
Yousef Altaf
on Stack Overflow
See other posts from Stack Overflow
or by Yousef Altaf
Published on 2012-09-22T14:34:13Z
Indexed on
2012/09/22
15:37 UTC
Read the original article
Hit count: 523
I'm running a mysqli query.
this is my code
<?php
$SM_pro_info="SELECT * FROM special_marketing_ads ORDER BY id desc LIMIT 4";
$QSM_pro_info = $db->query($SM_pro_info)or die($db->error);
if($QSM_pro_info->num_rows ==1){
while($SM_pro=$QSM_pro_info->fetch_object()){
?>
<table width="208" border="0">
<tr>
<td width="129" height="35" align="right"><span style="color:#361800; font-size:14px; font-weight:bold;"><?php echo $SM_pro->pro_title; ?></span></td>
<td width="69" rowspan="2" align="center"><a rel="lightbox" href="includes/Cpanel/projectImages//images.jpg" ><img src="<?php echo $SM_pro->image_1; ?>" alt="" width="60" height="60" border="0" /></a></td>
</tr>
<tr align="right">
<td><span style="color:#361800; font-size:14px; font-weight:bold;">?????</span> : <span style="color:#da6e19; font-size:15px; font-weight:bold;"><?php echo $SM_pro->pro_purpose; ?></span></td>
</tr>
</table>
<?php
}
}else{
echo"Your Ads here";
}
?>
now all I want to do is if there is any results comeing from mysqli echo it if there is no results it should echo an image which is add your ads here. the point is I have 4 Ads so if there is 1 Ads in mysqli row and the others is empty so I want it to echo this single Ads and the other 3 Ads should be this image add your Ads here. any Help on this please?
© Stack Overflow or respective owner