while ($ff = mysql_fetch_array($res)) { echo "$ff[cat_name]"; echo make_sub_list($ff['cat_subcat']).""; }//while