Hello I am trying to display groups of items that are linked to the primary key of another table. I would like to display the group headings and then the items that belong to that group below each heading.
I have created a recordset that basically does what I want but can’t figure out how to set up the looper to display all of the items under the Group Headings.
Here are my table structures:
Table 1.
Table Name: productLines
pk = Primary Key
productLine = Item Group Header Name
Table 2.
Table Name: productLit
pk = Primary Key
productLineId = value of productLines Primary Key
litName = Name of item
Here is my code you can also see it in action here: [url]http://www.marathonequipment.com/litlist_dev.php
[CODE]<?php require_once(‘Connections/marathon.php’); ?>
<?php
mysql_select_db($database_marathon, $marathon);
$query_rsLit = “SELECT * FROM productLit, productLines WHERE productLines.pk = productLit.productLineId GROUP BY productLit.productLineId”;
$rsLit = mysql_query($query_rsLit, $marathon) or die(mysql_error());
$row_rsLit = mysql_fetch_assoc($rsLit);
$totalRows_rsLit = mysql_num_rows($rsLit);
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Literature Download Page</title>
</head>
<body>
<h2>RamJet Waste Handling Equipment and Related Literature</h2>
<?php do { ?>
<p><strong><?php echo $row_rsLit[‘productLine’]; ?></strong><br />
<?php echo $row_rsLit[‘litName’]; ?><br /></p>
<?php } while ($row_rsLit = mysql_fetch_assoc($rsLit)); ?>
</body>
</html>
<?php
mysql_free_result($rsLit);
?>
I hope this makes sense, any help is greatly appreciated. Thanks!