Dinamik iki düzeyli liste php

0 Cevap php

I know, that this might be super easy, but probably, working late just halted my brains... All right. Here is my PHP, which is making two level dynamic list for me. http://robertr.pastebin.com/K2XvruPr

<?
    $last = NULL;
    $query = "SELECT s.id AS sect_id, s.name AS sect_name, s.alias AS sect_alias, c.name AS cat_name, c.alias AS cat_alias
    FROM data_sections s, data_categories c
    WHERE s.id = c.section_id
    AND s.deleted = 0
    AND c.deleted = 0";
    echo "<ul>\n";
    $result = mysql_query($query);
    while($list = mysql_fetch_array($result)){

        if($last!=$list['sect_name']) {
            echo "<li>".$list['sect_name']."</li>\n";
            $last = $list['sect_name'];
        }
        echo "<ul>";
        echo "<li>".$list['cat_name']."</li>";
        echo "</ul>\n";
    }
    echo "</ul>";
    ?>

Everything on view output looks nice, but source view is not like i want. robertr.pastebin.com/J7bPQeXj (copy paste in address bar).

Herkes her biri için, tüm kategoriler için sadece bir kez bu ikinci düzey UL etiketleri değil nasıl, bana anlamanıza yardımcı olabilir.

Teşekkürler!

0 Cevap