If you want to search your database by the 'surname' column that is fairly straight forward.
Use the uniquie 'id' field in the database to pass the details to the details page, in this case the unique column is just 'id'
<?php
//connect to database (use your own connection details)
$conn = new mysqli('server_name' , 'username' , 'password' , 'database_name);?>
<?php
if(isset($_POST['submit'])){
//get surname from form field
$surname= $_POST['surname'];
// get results to use in a REPEAT region
$sql = "SELECT * FROM table_name WHERE surname = '$surname' ORDER BY id ASC";
//get number of rows
$num_rows = $conn->query($sql)->num_rows;
//assign results to a variable
$listResults = $conn->query($sql) or die($conn->error);
}
?>
<h3>Search Database</h3>
<form name="search_database" method="post" action="">
<p><label for="surname">Surname</label>
<input type="text" name="surname">
</p>
<input type="submit" name="submit" value="Search" />
</form>
<?php if(isset($num_rows) && $num_rows > 0) {
echo "<h2>Results ($num_rows)</h2>";
}
?>
<?php while($row = $listResults->fetch_assoc()) { ?>
<p><a href="more_details.php?id=<?php echo $row['id']; ?>"><?php echo $row['surname']; ?></a></p>
<?php } ?>
<?php if(isset($num_rows) && $num_rows == 0) {
echo "<h2>Sorry No Results Found</h2>";
}
?>