<?
/*
CREATE TABLE IF NOT EXISTS `joins_customers` (
  `customer_id` int(11) NOT NULL auto_increment,
  `name` varchar(20) default NULL,
  PRIMARY KEY  (`customer_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

CREATE TABLE IF NOT EXISTS `joins_orders` (
  `product_id` int(11) NOT NULL auto_increment,
  `product` varchar(20) default NULL,
  `customer_id` int(11) default NULL,
  PRIMARY KEY  (`product_id`)
) 
*/

$db = mysql_connect("localhost", "mmaaaco_ksecor", "hamilton");
mysql_select_db("mmaaaco_mydb",$db);
$result = mysql_query("
select joins_customers.name
from joins_customers,joins_orders
where joins_customers.customer_id = joins_orders.customer_id
and joins_orders.product = 'Printer'
",$db);
?>
<table>
	<tr><td colspan="4"><a name="top"><h3>Student Practice Queries</h3></a>
</td>
	</tr>
	<tr>
	<th align="left">Name</th>
	</tr>
 <? 
 // display list if there are records to display. The %s is a placeholder for each field you select below
 	if ($myrow = @mysql_fetch_array($result)) {

      

      do {

        printf("<tr><td>%s</td></tr>\n",
         $myrow["name"]);

      } 
      while ($myrow = mysql_fetch_array($result));
  }
  ?>
  </table>    