I need to fix this code. It does work if I insert the correct information in the database also when i enter wrong information it gives me an empty page. WHAT I want is to show me a message if I enter wrong data. such as “Result not found”. I try to use IF and Else but I could not get it right
<?php include("config.php"); // connect to database include("heder.php"); ?> <?php $result = mysql_query("SELECT * FROM contacts where phoneNumber LIKE '$_POST[phoneNumber]%' " ) or die (mysql_error()); ?><h2>Search result</h2>
<table border="1" cellpadding="5" cellspace="5">
<tr>
<td><?php echo "First Name" ; ?></td>
<td><?php echo "Last Name" ; ?></td>
<td><?php echo "Phone Number" ; ?></td>
<td><?php echo "Zip Code" ; ?></td>
<tr>
<?php
while ($row = mysql_fetch_array($result)) { ?>
<tr>
<td><?php echo $row['firstName']; ?></td>
<td><?php echo $row['lastName'];?></td>
<td><?php echo $row['phoneNumber']; ?></td>
<td><?php echo $row['zipCode']; ?></td>
</tr>
<?php }
?>