Jump to content

if statement for getting no results


englishcodemonkey

Recommended Posts

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);


?>

Link to comment
https://forums.phpfreaks.com/topic/139376-if-statement-for-getting-no-results/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.