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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.