Re: GROUP BY? Urgent help needed with selection list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, first of all..  your subject line mentions GROUP BY which is a database function for telling the query what to use when performing aggregate functions like sum, count, average, etc type functions.

That's really not what you're looking at doing here it sounds like.  Sounds like you just want similar items alphebetized together while still keeping a 'region' like 'SE Akron' to display.

Probably the best thing you can do is have a City and have a Region.  City would be the major city that the region is near, like Akron and the Region (or whatever you want to call it) would be the area of the city that the data represents.

Then just do an ORDER BY on your City instead of Region.  you never have to display  the City if you don't want to.  But without having a giant cross reference database (that can't ever be complete) that can do the lookup of "SE Akron" and know that's actually Akron and not some suburb of Chicago or something, then you're going to have to tell it yourself.   I think this is the best solution for you.

Best of luck!

-TG

= = = Original message = = =

Hi there everyone,

 

I~m using the following code to populate cities from a huge database:

 

          <select name="fm_city[]" id="fm_city[]" multiple>

            <option value=0>Show All</option>

            <?

$sqla = "SELECT DISTINCT(Area) FROM MLS_Listings ORDER BY Area";

 

$sql_resulta = mysql_query($sqla,$connection)

            or die("Couldn't execute query.");

while ($row = mysql_fetch_array($sql_resulta)) 

   $Area = $row["Area"];

 

?>

            <option value="<?=$Area?>">

            <?=$Area?>

            </option>

            <? ; ?>

          </select>

 

This works great, no problems BUT the client now needs is so the cities are
grouped, but it~s not so simple.  For example, say you have Akron, Akron
Central etc ~. They need them so that ALL Akrons appear together, the
problem is, that also includes some which are SE Akron etc ~. So, of course
that appears further down the list under S.  How can I group this way?  I am
pretty lost on this.

 

Any help would REALLY be appreciated.

 

Chris


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 1/21/2005


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux