Hello
I am very much a newbie so please excuse the state of my code! I am building a very simple contact management system for a home delivery food service. Basically they need to be able to enter the customers phone number and get their full recordset returned. If there is no phone number on record they should be presented with a form with the phone number they entered for the search already completed in the relevant field of the new customer form.
The code below is what I have done so far for the initial search - enter phone number, get full record. I have been tearing my hair out over it for some hours now (!), at one point I had the search query working but can not get the echo results i'm looking for. Please see code below. any advice anyone can offer would be greatly appreciated.
I think i'm missing something really basic, but can no longer see the woods for the trees.
Thank you
zenrab
<?
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
mysql_connect(localhost,$username,$password);
@mysql_select_db($db_name) or die( "Unable to select database");
//check if form has been submitted
if ($_POST[submit] == "Search")
{
//Collect Form Data
$string = $_POST['search'];
//Issue SQL SELECT Statement
$result = mysql_query ("SELECT * FROM contacts WHERE telephone1 = '$string'");
}
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$firstname=("firstname");
$lastname=("lastname");
$address1=("address1");
$address2=("address2");
$district=("district");
$telephone1=("telephone1");
$telephone2=("telephone2");
$email=("email");
echo "<tr><td>First Name: $firstname</td><br>
<td>Last Name: $lastname</td><br>
<td>Telephone 1: $telephone1</td><br>
<td>Telephone 2: $telephone2</td><br>
<td>Address 1: $address1</td><br>
<td>Address 2: $address2</td><br>
<td>District: $district</td><br>
<td>Email: $email</td><br>";
?>