Make subcategories in template script

Discussion in 'PHP' started by jonas1045, Feb 1, 2012.

  1. #1
    I really need help with a script i have bought, the script has some categories, but i also need sub categories, so i added an extra field in the table traffic_categories. The original traffic_categories has id and category, but i have added sub_id also, so if the category is a main category it has 0 in sub_id, but if the category is a sub category it has the main category id in the sub_id field.. Simple..

    The problem is the script hava an advanced template system i can´t figure out how works. Here is the script that gets the categories from mysql:

    $result = mysql_query('SELECT category FROM traffic_categories WHERE sub_id = 0 ORDER BY category ASC;');
    $iCat=2;
    $CONF['categories'] = array(); $TMPL['cats'] = '';
    while(list($TMPL['cat']) = mysql_fetch_row($result)) {
        $TMPL['cath'] = str_replace(' ', '+', $TMPL['cat']);
        $TMPL['cats'] .= base::do_skin('menu/cats');
        $CONF['categories'][] = $TMPL['cat'];
    
            $TMPL['last'] = $iCat++ % 4 === 0 ? ' last' : '';
    }
    PHP:
    and here is cats.html:
    <div class="one-fourth{$last}">
        <h5><a href="/cat/{$cath}">{$cat}</a></h5>
        <ul class="categoryList">
            Here i want the subcategories--><li> - <a href=""></a></li>
        </ul>
    </div>
    HTML:
    and in my frontpage.html where the categories will be showed is just {$cats}.

    So if someone please can help me show the subcategories inside the list in cats.html where is have written "Here i want the subcategories-->", then i will be really glad, thanks.
     
    jonas1045, Feb 1, 2012 IP