Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grouping and diplay results mysql / php

Status
Not open for further replies.

NigeB

Technical User
Nov 29, 2000
53
GB
I am using a php / mysql combination to display a list of teams from around the globe. I can sort into country order no problem and county / state, but what I would like to do is display a group of all the teams in the same state together and put the teams in alphabetical order like thus

Alabama
first team name
second team name
third team name

Ohio
first team name
second team name

etc etc

my code is as follows so far, any suggestions appreciated

$result = mysql_query("SELECT * from teams_online where country ='United States' order by county, team_name", $db);

echo &quot;<table width=600 border=0>\n&quot;;

while ($myrow = mysql_fetch_array($result)){

printf(&quot;<tr><td width=50><td align=left><a href=\&quot;%s\&quot; onMouseOver=\&quot;MM_showHideLayers('%s','','show')\&quot; onMouseOut=\&quot;MM_showHideLayers('%s','','hide')\&quot;>%s</a>, <i>%s</i><span id=\&quot;%s\&quot; style=\&quot;position:absolute; width:400px; z-index:1; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 2px #FF0000; visibility: hidden\&quot;><font size=2 color=#FF0000>%s</font> </span></td></tr>\n&quot;,$myrow[&quot;website_url&quot;], $myrow[&quot;team_name&quot;], $myrow[&quot;team_name&quot;], $myrow[&quot;team_name&quot;], $myrow[&quot;county&quot;], $myrow[&quot;team_name&quot;],$myrow[&quot;description&quot;]);
}
echo &quot;</table>\n&quot;;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top