"; PRINT "Search"; PRINT ""; $dbname = "example"; $pname = $_POST["pname"]; $tqnt = $_POST["tqnt"]; /* MySQL table created to store the data */ $customer = "customer"; $product = "product"; $transaction = "transaction"; /* 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 tables */ $query = "SELECT *, sum(tqnt) FROM $customer, $product, $transaction WHERE $customer.cid = $transaction.cid and $product.pid = $transaction.pid and $product.pname = '$pname' group by customer.cname having sum(tqnt) >= $tqnt"; $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"); $sum = mysql_result($result, $i, "sum(tqnt)"); PRINT ""; PRINT ""; PRINT ""; PRINT ""; $i++; } PRINT "
$cname$sum
"; PRINT "
"; } PRINT "
"; PRINT "Back"; PRINT ""; PRINT ""; /* Close the database connection */ MYSQL_CLOSE(); ?>