My problem is that if a user types in a value that is not in my database the page stays blank. I wish to display a message saying their postcode is not valid. I have had a look through other posts and can't seem to get it to work with my code.

The user searches in a text box to find out the 'price' of delivery for their postcode i.e. they search m6 and it returns m6 - 0.50 in a table. If say they typed sk1, which is not part of the delivery area I want to display a message

What I have done is as follows:

index.php

```
<section id="post">
<p id="post"> postage calculator for manchester: </P>

    <?PHP
session_start();
     echo 'total cost £'. $_SESSION['postage'];
              ?>

    <form action="shop.php" method="post">
    <input class="text" type="text" name="postsub" min="0">
    <input class="button" type="submit" name="postsub1" value="postsub" >
    </form>
    </section>

```

process.php:

```
function button6() {

 $search_value = $_POST["postsub"];
 $codequery = "SELECT * FROM postage WHERE postcode LIKE '%$search_value%'";

 // connect to database
     $dbh= new PDO('mysql:host='.$hostname.';dbname='.$dbname,$username,$password);

  //generate SQL query
 $result=$dbh->prepare($codequery);

 //execute query
 $result->execute();

// display result
echo '<table id="tab">';
while($row=$result->fetch()){
echo '<tr>';
echo '<td>'.$row['postcode'].'</td>';
echo '<td>'.$row['price'].'</td>';
echo '</tr>';

 if (mysqli_num_rows($result)==0) { echo "no result"; }

  }
  echo '</table>';
 }

```

This is how it returns on a positive search and I just want the postode and price, and then when it is not any of those just display no result:

```
no resultno resultno resultno resultno resultno resultno result
m1  0.50
m2  0.50
m3  0.70
m4  0.70
m5  1
m6  1
m7  1.20

```