"; PRINT "Find Product"; PRINT ""; $dbname = "example"; $key = $_POST["key"]; $value = $_POST["value"]; /* MySQL table created to store the data */ $tablename = "product"; /* make connection to database */ MYSQL_CONNECT("localhost","nis","thomas") OR DIE("Unable to connect to database server"); @mysql_select_db("$dbname") or die("Unable to select database"); /* Select the data from the table */ $query = "SELECT * FROM $tablename WHERE $key = '$value'"; $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 product(s) in the database!

"; }else if ($number > 0){ PRINT "
"; PRINT "Product(s): $number

"; PRINT ""; while ($i < $number){ $pname = mysql_result($result, $i, "pname"); $pprice = mysql_result($result, $i, "pprice"); PRINT ""; PRINT ""; PRINT ""; PRINT ""; $i++; } PRINT "
$pname$pprice
"; PRINT "
"; } PRINT "
"; PRINT "Back"; PRINT ""; PRINT ""; /* Close the database connection */ MYSQL_CLOSE(); ?>