Parsing results from mySQL query
| From: | Charles Kline | Date: | Sat, 22 Mar 2003 14:15:03 +0000 |
| Subject: | Parsing results from mySQL query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140680@lists.php.net to get a copy of this message | ||
Hi everyone,
I have ALMOST gotten this working (mySQL part works).
I have gotten the advice that this is easier to do in PHP then to try and make this query work in mySQL. Here is the query and a sampling of the current results (from phpMyAdmin)
SELECT p.fname, p.lname,
w.web_link, a.dra_id, dra.area, t.titleFROM tbl_personnel p LEFT JOIN tbl_personnel_weblinks w ON p.id = w.person_id LEFT JOIN tbl_personnel_dras a ON p.id = a.person_id LEFT JOIN tbl_dra dra ON a.dra_id = dra.id LEFT JOIN tbl_personnel_titles t ON p.id = t.person_id; Because some of these people have multiple records in tbl_personnel_dras AND in tbl_personnel_titles - I get many repeats of each person (one for every combo). I was told this would be really messy to deal with in SQL (though I am open) - but I have no idea where to start in PHP. I would like to display the data to the web like: fname lname title(s) - (this would be the list of titles for this person) Areas: area, area, area (this would be the list of areas in one place as opposed to making the record repeat) Thank you for any help. The above query returns something like this (the first set are the column names): fname lname web_link dra_id area title Jeffrey Whittle NULL NULL NULL Investigator Jeffrey Whittle NULL NULL NULL Staff Physician Adam Gordon NULL 5 Mental Illness Staff Physician Adam Gordon NULL 5 Mental Illness Assistant Professor of Medicine Adam Gordon NULL 5 Mental Illness Investigator, VISN4 Mental Illness Research, Educa... Adam Gordon NULL 5 Mental Illness Investigator, Center for Research on Health Care Adam Gordon NULL 5 Mental Illness Investigator Adam Gordon NULL 8 Special (Underserved, High Risk) Populations Staff Physician Adam Gordon NULL 8 Special (Underserved, High Risk) Populations Assistant Professor of Medicine Adam Gordon NULL 8 Special (Underserved, High Risk) Populations Investigator, VISN4 Mental Illness Research, Educa... Adam Gordon NULL 8 Special (Underserved, High Risk) Populations Investigator, Center for Research on Health Care Adam Gordon NULL 8 Special (Underserved, High Risk) Populations Investigator