I am trying to create a page that queries a table containing team names and country to return a list thus
Belgium
Smiths Team
Jones Team
Rogers Team
Holland
Sithy's Team
Peters Team
etc etc,
I have written a query, but unfortunatly it only returns the first country and teams from that country, any pointers as to the errors greatly appreciated -
Nigel
Code -------
$query1 = "SELECT DISTINCT country FROM teams_online";
$result1 = mysql_query($query1);
while ($row = mysql_fetch_array($result1)) {
$region = $row"country";
$query2 = "SELECT * from teams_online where country ='$region' order by team_name";
$result2 = mysql_query($query2);
}
mysql_free_result($result1);
if ($myrow = mysql_fetch_array($result2)){
echo "<table width=600 border=0><tr><td>'$region'</td></tr>\n";
$i =1;
do{
printf("<tr><td>%s</td><td>%s</td></tr>\n", $i, $myrow"team_name"
$i++;
} while ($myrow = mysql_fetch_array($result2));
echo "</table>\n";
} else {
echo "Sorry, no Team records were found!";
}
Belgium
Smiths Team
Jones Team
Rogers Team
Holland
Sithy's Team
Peters Team
etc etc,
I have written a query, but unfortunatly it only returns the first country and teams from that country, any pointers as to the errors greatly appreciated -
Nigel
Code -------
$query1 = "SELECT DISTINCT country FROM teams_online";
$result1 = mysql_query($query1);
while ($row = mysql_fetch_array($result1)) {
$region = $row"country";
$query2 = "SELECT * from teams_online where country ='$region' order by team_name";
$result2 = mysql_query($query2);
}
mysql_free_result($result1);
if ($myrow = mysql_fetch_array($result2)){
echo "<table width=600 border=0><tr><td>'$region'</td></tr>\n";
$i =1;
do{
printf("<tr><td>%s</td><td>%s</td></tr>\n", $i, $myrow"team_name"
$i++;
} while ($myrow = mysql_fetch_array($result2));
echo "</table>\n";
} else {
echo "Sorry, no Team records were found!";
}