englishcodemonkey Posted January 3, 2009 Share Posted January 3, 2009 Hi guys, So i'm trying to display an image with the code $picname = $row["fileContents"]; } echo "<img src = '$picname' >"; but if there are no results in internet explorer it shows a red X since it cant find the image, i've tried using "if(mysqli_num_rows($r)==0)" but this doesnt work. i'm using mysqli and so wondered if anyone had any other ideas.the query is shown below this: $q = "SELECT description from hosta where hosta_name='$hosta1'"; $r = mysqli_query ($dbc, $q); if ($r) { echo ' <table align="center" cellspacing="3" cellpadding="3" width="90%"> <tr> <td align="left"><b>Description</b></td> </tr>'; while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) { echo ' <tr> <td align="justify">' .$row['description'] . '</td> </tr>'; } } echo '</table>'; $dbc = mysqli_connect ('****', '****', '****', '****'); $sqlimage = "SELECT * from image, hosta WHERE id=hosta_id and hosta_name = '$hosta'"; $sql_imgresult = mysqli_query($dbc,$sqlimage); while ( $row = mysqli_fetch_array ($sql_imgresult) ) { $picname = $row["fileContents"]; } echo "<img src = '$picname' >"; mysqli_close($dbc); ?> Quote Link to comment https://forums.phpfreaks.com/topic/139376-if-statement-for-getting-no-results/ Share on other sites More sharing options...
fenway Posted January 4, 2009 Share Posted January 4, 2009 if() statements aren't mysql-related... prove that the query doesn't fail... check mysql error, make sure some rows are being returned, etc Quote Link to comment https://forums.phpfreaks.com/topic/139376-if-statement-for-getting-no-results/#findComment-729261 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.