You are here: Re: display multiple « All PHP « IT news, forums, messages
Re: display multiple

Posted by J.O. Aho on 03/01/07 12:46

Pankaj wrote:
> Hi,
>
> My sql query is giving me multiple records - producers, masters and
> models. I want to display all models belonging to a particular
> producer in a table column seperated by comma. However, I am unable to
> do so. All my records get displayed in a seperate row. How can I get
> this done.
>
First you have to join the tables

SELECT * FROM Producers, Models WHERE Producers.producer_id=Models.producer_id

When you loop throw the results for the query you will then need to store
those values into a array

while($row=....) {
$array[$row['producer_name']][]=$row['model_name'];
}

Now you have a multidimensional array, with model_names linked to each
producer, all you have to do is to implode() the subarray with the
model_name's and you get your comma separated strings of models.


--

//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация