This is a discussion on "PHP/Mysql issue..." within the PHP Forum section. This forum, and the thread "PHP/Mysql issue... are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP/Mysql issue...
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
PHP/Mysql issue...
Hi all!
I have a problem concerning data retrieval and ,in particular, how they are shown to the user. To be more specific, assume we have the following tables[Mysql database]: id name vehicle 1 nick LOTUS 2 nick BMW 3 peter MASERATI 4 mary FERRARI 5 lisa PEUGEOT 6 peter HARLEY 7 peter SEAT 8 lisa MERCEDES 9 steven LADA 10 george JEEP If you run a query like: $query = "SELECT name, vehicle from TABLE"; you will get the 10 rows as expected. When it comes to printing, you have: $result = mysql_query($query); while ($line = mysql_fetch_row($result) ) { echo $line[0]."\t".$line[1]; } where, $line[0] is NAME and $line[1] is VEHICLE and you get : nick LOTUS nick BMW peter MASERATI mary FERRARI peter HARLEY peter SEAT ... ... What I want to do is print the results in the following way: nick: LOTUS|BMW peter: MASERATI|HARLEY|SEAT mary: FERRARI lisa: PEUGEOT|MERCEDES steven LADA george JEEP that is, have one row per person. Is this done by , somehow, checking in the 'while loop' for something ,or is there a special function in Mysql that I am not aware of? |
|
|
|
|||
|
Re: PHP/Mysql issue...
In your sql query sort by name, then...
|
|
|||
|
Re: PHP/Mysql issue...
Even simpler than that since you are using mysql use group_concat in your query.
|
![]() |
| Tags |
| phpmysql, issue |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| css issue | acrikey | Web Page Design | 16 | Jul 25th, 2007 18:37 |
| css issue | acrikey | Web Page Design | 4 | May 24th, 2007 16:01 |
| an IE issue | sxc | Web Page Design | 3 | Apr 23rd, 2007 18:37 |
| Help Odd Issue? | drappendix | Web Page Design | 8 | Aug 9th, 2006 17:53 |
| CSS IMG gap issue | sisyphus74 | Web Page Design | 1 | May 16th, 2005 17:46 |