<?include "conninfo.php";

$sn=$_POST["sname"];


$query="SELECT * FROM people WHERE surname like ?";
$stmt=mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt,$query);//prepare statement

mysqli_stmt_bind_param($stmt,"s",$sn);//bind $sn to statement

mysqli_stmt_execute($stmt);

$result=mysqli_stmt_get_result($stmt);

$numberfound=mysqli_num_rows($result);

if($numberfound>0)
{
echo "We found:<br>";
while($r=mysqli_fetch_array($result))
	{
	echo $r["id"]." ";
	echo $r["firstname"]." ";
	echo $r["surname"]." ";
	echo $r["postcode"]."<br>";
	
	}
}
else
{
	echo "Sorry nothing was found";
}
?>