i have got solution thanks.
$resultMainMenu = mysql_query("SELECT * FROM test WHERE refid=0 ORDER BY name ASC") or die(mysql_error());
while($row = mysql_fetch_array($resultMainMenu)){
echo $row['name'] . '<br />';
$resultSubmenu = mysql_query("SELECT * FROM test WHERE refid=" . $row['id'] ." ORDER BY name ASC") or die(mysql_error());
if(mysql_num_rows($resultSubmenu) >= 1){
while($rowSub = mysql_fetch_array($resultSubmenu)){
echo ' -- ' . $rowSub['name'] . '<br />';
}
}
}