<?include "conninfo.php";
$srch=$_POST["search"];//bring from POST data


echo "My database contents:<br><br>";

$query="SELECT * FROM people WHERE surname like '$srch'";
$result=mysqli_query($link,$query)or die("didnt work");
$numrows=mysqli_num_rows($result);


if($numrows==0)//nothing found in database (no rows matching)
{
	echo "Sorry nothing found";
}
else
{
	echo $numrows." results found:<br><br>";
	
	while($r=mysqli_fetch_array($result))
	{
	$postcode=$r["postcode"];
	$postcode=strtoupper($postcode);
	echo $r["id"]." ";
	echo $r["firstname"]." ";
	echo $r["surname"]." ";
	echo $r["favfood"]." ";
	echo $postcode."<br>";
	}
}
?>