<html>
<head><title>Search Results</title>

<?
//include stylesheet for formatting
include("stylesheet.php3");
?>

</head>
<body>

<?
// script to query inventory based on user-entered text strings

// connection information
$hostName "dbm2.itc.virginia.edu";
$userName "mst3k";
$password "secret";
$dbName "mst3k_Inventory";

// make connection to database
mysql_connect($hostName$userName$password) or die("Unable to connect to host $hostName");

mysql_select_db($dbName) or die("Unable to select database $dbName");

// Select all the fields in the Employees table for
// records that match the form entries
$query =
        
"SELECT inventory.dateAcquired, inventory.comments,
                employees.firstName, employees.lastName, 
        computers.computerDescription
        FROM inventory, employees, computers
        WHERE ((employees.firstName LIKE '$firstName%')
              and (employees.lastName LIKE '$lastName%')
          and (inventory.employeeID = employees.employeeID)
                and (inventory.computerID = computers.computerID))
        ORDER BY employees.lastName, employees.firstName"
;

$result mysql_query($query);

// Determine the number of employees
$number mysql_numrows($result);

if (
$number == 0) {
   print 
"Sorry, there were no records matching those criteria";
} else {
   print 
"<h2>There are $number matching records in the inventory:</b></h2><p>
        <table cellpadding=5>
        <tr bgcolor=black>
          <td><font color=white><b>Name</b></td>
          <td><font color=white><b>Computer Description</b></td>
          <td><font color=white><b>Date Acquired</b></td>
          <td><font color=white><b>Comments</b></td></tr>"
;
   
// Print the employee names
   
for($i=0$i<$number$i++){
    
$firstName mysql_result($result,$i,"firstName");
    
$lastName mysql_result($result,$i"lastName");
    
$computerDescription mysql_result($result$i"computerDescription");
    
$dateAcquired mysql_result($result$i"dateAcquired");
    
$comments mysql_result($result$i"comments");
        
/* print even-numbered rows with a grey background, 
           odd-numbered with a white background */
        
if ($i%== 0) {
                print 
"<tr bgcolor=lightgrey>";
        } else {
                print 
"<tr>";
        }
        print 
"<td>$lastName, $firstName</td>
        <td>$computerDescription</td>
        <td>$dateAcquired</td>
        <td>$comments</td></tr>"
;
   }
   print 
"</table>";
}

// Close the database connection
mysql_close();

?>

<p>
<a href="multiCondition.phps">
<font color="red">View the source of multiCondition.php3</font></a><p>
<a href="stylesheet.phps">
<font color="red">View the source of stylesheet.php3</font></a>
</body>
</html>