Your SQL statement shoud join the 2 tables like this:
Code:
SELECT
s.subcatName
,m.merchant_name
,m.thumb_nail
FROM
subcategory s
LEFT JOIN
merchant m
ON
m.msubcid = s.subcid
ORDER BY
s.subcatName
ASC
Then when you loop through the results, just set check for /set the category:
Code PHP:
$currentCat = '';
while($row = mysql_fetch_array($query)) {
extract($row);
if ($currentCat != $subcatName) {
//if a new category, write category head
echo "<tr><td colspan=\"2\"><h1>$subcatName</h1></td></tr>";
$currentCat = $subcatName;
} else {
echo "<tr><td>$merchant_name</td><td>$thumb_nail</td></tr>";
}
}
Does that help you out any?
Bookmarks