multiple rows => 1row???

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 30th, 2005, 10:00
Up'n'Coming Member
Join Date: Sep 2005
Location: athens
Age: 25
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
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!
Reply With Quote

  #2 (permalink)  
Old Dec 31st, 2005, 21:30
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
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";
}
Reply With Quote
Reply

Tags
multiple, rows, 1row

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 05:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43