Page 1 of 1

Show message if mysql_query returns no results

Posted: Sat May 01, 2010 3:46 pm
by jeffyyy
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
	}
?>

Re: Show message if mysql_query returns no results

Posted: Sat May 01, 2010 4:52 pm
by phu