Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need help queriying sub categories


Assailantnyc

Recommended Posts

Posted

EDIT: bah this was supposed to go into the Installation and Configuration section! sorry about that.

 

hello, im not too advanced with php but im pretty sure theres a simple fix for this. right now I have a dynamic menu that reads the products from a given category. Instead of the products inside that category, I would like it to read the categories (sub categories) inside that category. im pretty sure its just a line or two code change from changing it to query the products to the categories. heres the function:

 

<?
function menu_show_products($cat) {
 $html = '<ul>';
 $cat = intval($cat);
 $data_query = mysql_query("SELECT pd.products_name, pd.products_id FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c WHERE pd.products_id = p2c.products_id AND p2c.categories_id = '" . $cat . "' AND pd.language_id = '" . $_SESSION['languages_id'] . "'");
 while($data = mysql_fetch_assoc($data_query)) {
$html .= '<li><a href="' .  tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $data['products_id']). '">' . stripslashes($data['products_name']) . '</a></li>';
 }

 $html .= '</ul>';
 return $html;
}
?>

 

and heres what calls it into action to display the products:

 

<a href="<?=tep_href_link(FILENAME_DEFAULT, 'cPath=26');?>">Collections</a>
			<?
			echo menu_show_products(26);
			?>

 

any help is greatly appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...