Load-This Posted March 22, 2007 Posted March 22, 2007 Hey People, I am try to modify a bit of code to work for me, but im stuck on a bit ... i will explain. I have the following code that displays the parent categories which works a treat <?php $crazyparent_query = 'AND (c.parent_id = "0")'; $crazyresult = tep_db_query('select c.categories_id, cd.categories_name, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$crazyparent_query.'order by sort_order, cd.categories_name'); while ($crazyrow = tep_db_fetch_array($crazyresult)) { $crazytable[$crazyrow['parent_id']][$crazyrow['categories_id']] = $crazyrow['categories_name']; ?> <li><a href="" title="<?php print $crazyrow['categories_name']; ?>"><?php print $crazyrow['categories_name']; ?></a></li> <?php } ?> This works perfect, but i need to also display the path to get to these parent categories in the href="" bit. I hope that makes sense, and i really hope someone can help out. Cheers all
Load-This Posted March 22, 2007 Author Posted March 22, 2007 Hey ... I managed to figure it out, just incase anyone wants to know, i have posted the code here. <?php $crazyparent_query = 'AND (c.parent_id = "0")'; $crazyresult = tep_db_query('select c.categories_id, cd.categories_name, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$crazyparent_query.'order by sort_order, cd.categories_name'); while ($crazyrow = tep_db_fetch_array($crazyresult)) { $crazytable[$crazyrow['parent_id']][$crazyrow['categories_id']] = $crazyrow['categories_name']; $crazycPath_new = 'cPath=' . $crazyrow['categories_id']; $crazystring = tep_href_link(FILENAME_DEFAULT, $crazycPath_new) . '"'; ?> <li><a href="<?php echo $crazystring; ?> title="<?php print $crazyrow['categories_name']; ?>"><?php print $crazyrow['categories_name']; ?></a></li> <?php } ?>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.