This is a discussion on "multiple rows => 1row???" within the PHP Forum section. This forum, and the thread "multiple rows => 1row??? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
multiple rows => 1row???
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
multiple rows => 1row???
Hi all and Merry Christmas!
I wanted to ask how would I deal with the following problem: Say I have a table [TABLE1]: customerid name 1 nick 2 george 3 harry and a [TABLE2]: number car 1 Lotus 2 BMW 2 FERRARI 2 LADA 3 Lamporgini If I want to see george's car, I would write: SELECT car from TABLE2 where number ='2'; and I would get : BWM FERRARI LADA The thing is that I don't want to get 3 lines, but just one, where each record will be separated e.g. by TAB. But with mysql_fetch_array I will get 3 lines. I must somehow "check" for each person if he has more than one cars, and show them in one row, not in multiple rows. I am stuck! |
|
|
|
|||
|
Re: multiple rows => 1row???
The easiest way would be to write a loop to fetch back the three rows, and join together the results you get back with a .= operator ... something like ...
$rs = mysql_query("Select ..... "); $result = ""; while ($row = mysql_fetch_assoc($rs)) { $result .= $row[car] . "\t"; } |
![]() |
| Tags |
| multiple, rows, 1row |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Blank Space between 2 rows | JunkFood | Web Page Design | 1 | Mar 26th, 2008 22:33 |
| Columns and Rows | tlo5 | JavaScript Forum | 4 | Nov 20th, 2007 16:13 |
| mimic table rows | flann | Web Page Design | 5 | Apr 13th, 2007 23:30 |
| IE Fast rows insertion. | ronen | JavaScript Forum | 1 | Mar 21st, 2007 22:51 |
| SQL Syntax for adding multiple rows together from 1 column | jfergy | Databases | 3 | Jan 17th, 2006 04:12 |