Hello
I am having problems with my echo, the screen is blank. Can anyone offer any insight: Code below.
I am trying to achieve the following:
Put customer phone number in search; if record there, display full record, if not there return form with entered phone number in place and all other fields empty.
Many thanks in anticipation
<?php
$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");
if ($_POST[submit] == "Search")
{
//Collect Form Data
$string = $_POST['search'];
//Issue SQL SELECT Statement
$query = "SELECT * FROM contacts WHERE telephone1 = '$string'";
$result = mysql_query($query) or die(mysql_error());
$mysql_num = mysql_num_rows($result );
if ($mysql_num == 0)
{
print "<tr>";
print "<td>First Name:";
print "<td><input name='firstname' type='text'></td>";
print "</td>";
print "<td>Last Name:";
print "<td><input name='lastname' type='text'></td>";
print "</td>";
print "<td>Address 1:";
print "<td><input name='address2' type='text'></td>";
print "</td>";
print "<td>Address 2:";
print "<td><input name='address2' type='text'></td>";
print "</td>";
print "<td>Telephone 1:";
print "<td><input name='telephone1' type='text' value='"; echo $string; print "'></td>";
print "</td>";
print "<td>Telephone 2:";
print "<td><input name='telephone2' type='text'></td>";
print "</td>";
print "<td>Email:";
print "<td><input name='email' type='text'></td>";
print "</td>";
print "</tr>";
}
else
{
// enter your code here if your query finds a customer with the number your searching for
while($row = mysql_fetch_array($result))
{
print "<tr>";
print "<td>First Name:";
echo $row['firstname'];
print "</td>";
print "<td>Last Name:";
echo $row['lastname'];
print "</td>";
print "<td>Address 1:";
echo $row['address1'];
print "</td>";
print "<td>Address 2:";
echo $row['address2'];
print "</td>";
print "<td>Telephone 1:";
echo $row['telephone1'];
print "</td>";
print "<td>Telephone 2:";
echo $row['telephone2'];
print "</td>";
print "<td>Email:";
echo $row['email'];
print "</td>";
print "</tr>";
}
}
}
?>