İstediğiniz şey şu resmin:
Bu hale gelmesi ise:
Şöyle basit bir kod yardımı ile yapabilirsiniz:
<?php
header('Content-Type:text/html; charset="UTF-8"');
mysql_connect('localhost','root','');
mysql_select_db('ust');
$sorgu = mysql_query("select * from tablo where ustid = 0");
if(mysql_num_rows($sorgu) > 0){
echo '<ul>';
while($veri = mysql_fetch_object($sorgu)){
echo '<li>';
echo $veri->isim;
$sorgu2 = mysql_query("select * from tablo where ustid = '".$veri->id."'");
if(mysql_num_rows($sorgu2)>0){
echo '<ul>';
while($veri2 = mysql_fetch_object($sorgu2)){
echo '<li>'.$veri2->isim.'</li>';
}
echo '</ul>';
}
echo'</li>';
}
echo '</ul>';
}else{
echo 'Ülke yok.';
}
?>