<?php
$sql = mysqli_connect("localhost","root","","atilim");

function KategoriListesi($id,$secim,$tire)
{
    global $sql;
    $sorgu = $sql->query("SELECT * FROM category WHERE cat_id='".intval($id)."' ORDER BY cat_name ASC");
    while ($row = $sorgu->fetch_array())
    {
        if ($row['cat_id'] == 0) {
            $tire = 0;
        }

        if ($secim != $row['cat_id'])
        {
            $secim = $row['cat_id'];
            $tire++;
        }
        
        
        echo str_repeat('-&nbsp;',$tire).$row['cat_name']."<br>";
        KategoriListesi($row['id'],$secim,$tire);
    }
}
KategoriListesi(0,0,0);
?>
Ceviz Forum - View Single Post - kategori ve alt kategorileri yapmaya çalışıyorum olmuyor..

Ayrıca tek seferde bir dizi de toplayıp sonrada bu diziden listelersen performansını kat kat artırmış olursun. yukarıdaki kod seninkinden daha performanslı çalışacaktır.