$sorgu = "SELECT * FROM kategoriler WHERE ust = 0 AND aktif = 1 ORDER BY id asc"; $sonuc = mysql_query($sorgu); $ana_toplam = mysql_num_rows($sonuc); if($ana_toplam != 0) { $i = 1; while($kayit = mysql_fetch_object($sonuc)) { echo "submenu[".$i."]='"; $no_alt = $kayit->id; $sorgu_alt = "SELECT * FROM kategoriler WHERE ust = $no_alt ORDER BY id asc"; $sonuc_alt = mysql_query($sorgu_alt); $ana_toplam_alt = mysql_num_rows($sonuc_alt); if($ana_toplam_alt != 0) { while($kayit_alt = mysql_fetch_object($sonuc_alt)) { echo "id."\">".$kayit_alt->tanim." | "; } } echo "'"; $i++; } }