I am trying to create a search page so that the user can type in a string that will search the surname column and return all information in the row.
Here is my code:
Code: Select all
<?php
mysql_connect ("localhost", "myuser", "mypassword") or die (mysql_error());
mysql_select_db ("enquiries");
$search = $_POST['search'];
$sql = mysql_query("select * FROM enquiry WHERE surname LIKE '%search%'");
while ($row = mysql_fetch_array( $sql ))
{
echo 'Firstname: '.$row['firstname'];
echo '<br/>Surname: '.$row['surname'];
echo '<br/>Tutor: '.$row['tutor'];
}
?>Any help would be appreciated.