Just a quick note, you wouldn't base it upon $description would you? It really depends on your data, but consider these four records:
Fred Flintstone Bedrock (shared house) Wilma Flintstone Bedrock (shared house) Homer Simpson Springfield (shared house) Marge Simpson Springfield (shared house) By testing for (shared house), you'd end up grouping them together like this: Fred Flintstone Wilma Flintstone Homer Simpson Marge Simpson Bedrock (shared house) ... which isn't your intended result. Really, what you'd like to do is group people together based on their premises being the same. This of course is complicated by the fact that if the premises is misspelled, or changed slighly (Unit 2, Suite 2, U2, etc etc), the records won't match, and you won't be able to establish a connection between the two Doctors. If you have a lot of these types of records, yes, you may wish to do something about it, but if it's only a few, I'd leave it be. The real solution is a change in your data design. What you actually want is to relate Doctors to their premises/practice. Hence, I would have a table of Doctors, and a table of Premises, with an id being the key for each. This way Doctor #2 and Doctor #15 can both be associated with Premises #5. Better still, a Doctor may be associated with one or more practices. This seems like a smarter/quicker/faster/more future proof method than hoping for matches in the address and performing complex array sorts. Then again, I'm not an array expert :) Two relational tables seem like the best result to me, although it might create additional work at this early stage. Justin French -------------------- Creative Director http://Indent.com.au -------------------- on 11/04/02 9:20 PM, Christoph Starkmann ([EMAIL PROTECTED]) wrote: > Hi folks! > > The following problem: > > I got a db (mysql) with information about doctors. > Name, adress, phone etc. > > Now I'm reading these information with a simple > mysql-query: > > $queryString = "SELECT DISTINCT m.$sureName, m.$preName, m.$prax, m.$title, > "; > $queryString .= "p.$town, p.$zip, p.$phone, p.$description "; > $queryString .= "FROM $medTable m, $praxTable p WHERE "; > $queryString .= "m.$prax = p.$id"; > > Normally, I print out the information like this: > > Dr. med. John Doe // $title, $preName, $sureName > (shared practice) // description > Elmstreet 13 // $street > 666 Amityville 23 // $zip, $town > phone: 0049 - 815 - 4711 // $phone > > Okay. Now some of these folks are sharing a practice > ($description in the above code == "shared practice"). > > I would like to have these grouped together like this: > > Dr. med. John Doe // $title, $preName, $sureName > Dr. med. Allan Smithee > (shared practice) // description > Elmstreet 13 // $street > 666 Amityville 23 // $zip, $town > phone: 0049 - 815 - 4711 // $phone > > I am starting to get a little confused right here and right now. > This is the reason for being THIS detailed, too ;) Don't want to > mix anything up. > > How would you achieve this goal fastest and "best"? > Creating a temp array and checking for double $description-s > which I store in the temp array and delete from the original one? > Or check this with the original array? How? > I found functions to get the value for one key in a hash, but not > for several values with the same key... > > Sorry for the confusion, starting to get fuzzy... > > Any ideas, hints? > > Thanx alot, > > Kiko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php