/* this script will handle the variables passed from the insert_customer.html file */
/* declare some relevant variables */
PRINT "";
PRINT "
Find Customer";
PRINT "";
$dbname = "example";
$key = $_POST["key"];
$value = $_POST["value"];
$log = $_POST["log"];
$key2 = $_POST["key2"];
$value2 = $_POST["value2"];
/* MySQL table created to store the data */
$tablename = "customer";
/* make connection to database */
MYSQL_CONNECT() OR DIE("Unable to connect to database server");
@mysql_select_db("$dbname") or die("Unable to select database");
/* Select the data from the table */
if($log == '')
$query = "SELECT * FROM $tablename WHERE $key = '$value'";
else
$query = "SELECT * FROM $tablename WHERE $key = '$value' $log $key2 = '$value2'";
$result = MYSQL_QUERY($query);
/* How many rows in the result? */
$number = MYSQL_NUMROWS($result);
/* Print these results to the screen in a nice format */
$i = 0;
if ($number == 0){
PRINT "No such customer(s) in the database!
";
}else if ($number > 0){
PRINT "";
PRINT "Customer(s): $number
";
PRINT "";
while ($i < $number){
$cname = mysql_result($result, $i, "cname");
$ccity = mysql_result($result, $i, "ccity");
$cphone = mysql_result($result, $i, "cphone");
PRINT "";
PRINT "$cname | ";
PRINT "$ccity | ";
PRINT "$cphone | ";
PRINT "
";
$i++;
}
PRINT "
";
PRINT "";
}
PRINT "
";
PRINT "Back";
PRINT "";
PRINT "";
/* Close the database connection */
MYSQL_CLOSE();
?>