Source code of dbUpdate1.php

<html>
<head>
<title>Updating information in a database</title>
</head>
<body>
<h2>Updating Prices</h2>
<p>Click on a price to update it</p>
<?php

  
// Rather than listing my MySQL password directly in this PHP
  // page, I've stored it in an external file

  
function printCell($value) {
    print 
"<td>$value</td>\n";
  }

  
$allLines file("mysql.txt");
  
$password trim($allLines[0]);
  
$dbLink mysql_connect("localhost""tboegel"$password);

  
mysql_select_db("clearwater"$dbLink);

  
$query "SELECT item_desc, inv_price, inv_id, color, inv_size "
    
"FROM inventory, item "
    
"WHERE inventory.item_id = item.item_id "
    
"ORDER BY item_desc, color, inv_size";
  
$recordset mysql_query($query$dbLink);

  print 
"<table border=1>";
  print 
"<tr><th>Item</th><th>Color</th><th>Size</th><th>Price</th></tr>";
  while (
$row mysql_fetch_assoc($recordset)) {
    print 
"<tr>\n";
    
printCell($row['item_desc']);
    
printCell($row['color']);
    
printCell($row['inv_size']);
    
$url "http://hills.ccsf.edu/~tboegel/dbUpdate2.php?inv_id="
      
$row['inv_id'];
    print 
"<td><a href='$url'>" $row['inv_price'] . "</a></td>\n";
    print 
"</tr>\n";
  }
  print 
"</table>";

  
mysql_free_result($recordset);

  
mysql_close($dbLink);

?>

</body>
</html>