adamjblakey Posted July 6, 2007 Share Posted July 6, 2007 Hi, The code below i have used in a none smarty site which is used to display categories and subcategories which works fine but now i want to use it in a smarty template site but am unsure how to assign these correctly and how to display them. <?php $strippagename = str_replace("-", " ",$_GET['title']); $sql = "SELECT category, GROUP_CONCAT(DISTINCT '<a href=\"/recipessubcat/',REPLACE(category2,' ','-'),'.html\" class=\"subcategories\">',category2,'</a>' ORDER BY category2 SEPARATOR ', ') as subcats FROM recipes GROUP BY category" ; $res = mysql_query($sql) or die (mysql_error()."<p>$sql</p>"); $k=0; while (list($cat, $subs) = mysql_fetch_row($res)) { $cat_url = strtr($cat, "éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ. ","eeeaeauoiaabcdefghijklmnopqrstuvwxyz--"); $cat_url = ereg_replace('[^a-zA-Z0-9_-]', '', $cat_url); echo "<div style='float: left; padding:6px; width: 30%; '> <a href='recipescat/$cat_url.html' class='categories'><h1>$cat</h1></a>$subs</div>"; $k++; if ($k % 3 == 0) echo "<br style='clear:both' />\n"; } ?> Any help would be much appreciated. Cheers, Adam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.