/    Sign up×
Community /Pin to ProfileBookmark

Help with query by groups

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[/url]

[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);
?>[/CODE]

I hope this makes sense, any help is greatly appreciated. Thanks!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@monkeyboneauthorSep 15.2006 — Would anyone be willing to help me if I offered up some Government cheese? ;-)~
×

Success!

Help @monkeybone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...