Hi
I need some help!
I have some code that displays a menu. The menu has categories of products, some of these categories have subcategories.
When a category is clicked, the class is sent to some jquery/ajax and when a subcategory is clicked the class is also sent to the jquery/ajax. This is working fine.
The problem I have is that if I click any subcategory in a category only the data for one subcat is shown for all the subcat.
This is the code
<?php
include 'connect.php';
$q = "SELECT c.category, c.cat_id, s.subcat_id, GROUP_CONCAT(s.subcategory) AS sublist FROM categories AS c LEFT JOIN subcategories AS s ON c.cat_id = s.cat_id GROUP BY c.cat_id ORDER BY c.cat_id ";
$r = mysql_query($q) or die( 'Could not execute query: ' . mysql_error() );
$output = '<ul id="nav">';
while($data = mysql_fetch_array($r)){
$output .= "<li><a href={$data['cat_id']} class='category'>{$data['category']}</a>";
if(!empty($data['sublist'])){
$subcats = explode(",", $data['sublist']);
$output .="<ul>";
foreach($subcats as $s){
$output .= "<li><a href={$data['subcat_id']} class='subcategory'>$s</a></li>";
}
$output .= "</ul>";
}
$output .="</li>";
}
$output .= '</ul>';
echo $output;
Can anyone see what the problem is?
Thanks for looking.
Glen