The easiest way is to join the two tables and order by the result set by country:
select * from employee join country on (employee.countryid =country.id) order by country.name;
then, when printing them out, to get the cool country1:
username1
username2
country2:
username3
layout, you can use a while statement:
$country_test = result($res,0,'country');
$country = "bogus country name";
for ($i=0;$i<$count_of_recs;$i++){
if ($country_test!=$country) {
print "<div>".$countr.":<BR>";
$country_test = $country;
}
$country = result($res,$i,'country');
print result($res,$i,'personname')."<BR>";
}
something like that.