Another way to do this would be to query MySQL initially just for the
valid states in whatever order needed, print that state name, then do
another query to find all cities within that state.  HTH!





--- In [email protected], Pete <[EMAIL PROTECTED]> wrote:
>
> In message <[EMAIL PROTECTED]>, William Watson
> <[EMAIL PROTECTED]> writes
> >I am trying to create a query to get the results to look like this 
> >(showing each state only once instead of several times, and list all 
> >cities underneath their corresponding state, in ascending order):
> >
> >Example 2:
> >
> >ALABAMA
> >- Huntsville
> >- Montgomery
> >- Talladega
> >
> >etc, etc.
> >
> >I don't have another table that is storing the cities, separate from 
> >the states. Is this the problem? Can anybody explain to me what I 
> >need to do to make up a query that will work to output the results 
> >like I need them? I greatly appreciate any assistance and/or code you 
> >can provide to help me.
> 
> You can't do this by SQL alone - some records would have to return state
> names, some would have to return town names.
> 
> The simplest way is to SELECT... ORDER BY state, city  This would return
> all the cities, split up by states.
> 
> Then your PHP code would have to read:
> $laststate=''
> {while more records, read another
> if state<>$laststate echo $state; $laststate=State;
> echo city
> }
> -- 
> Pete Clark
> 
> Sunny Andalucia
> http://www.hotcosta.com/comm_1.htm
>


Reply via email to