Show message if mysql_query returns no results
Posted: Sat May 01, 2010 3:46 pm
Here is what I have, I need it to display a message if the query returns no results. Thanks!
Code: Select all
<?php
$term = $_POST['term'];
$sql = mysql_query("select * from messages where tag like '$term'");
while ($row = mysql_fetch_array($sql)){
?><table width="75%" padding="0" border="1">
<tr>
<td width="65%">
<a id="inline" href="#<?php echo ''.$row['message_id'];?>">
<?php echo 'Message From: '.$row['name'];?></a>
</td>
<td><br /> <?php echo ' '.$row['date'];?></td>
<div style="display:none">
<div id="<?php echo ''.$row['message_id'];?>">
<?php echo 'Message:<br /> '.$row['message'];?>
</div>
</div>
</td>
</tr>
</table>
<?php
}
?>