You are here: Re: arranging data results in multiple tables. « PHP SQL « IT news, forums, messages
Re: arranging data results in multiple tables.

Posted by toodi4 on 12/07/06 04:24

toodi4 wrote:
> I'm trying to arrange some data output that will go into a series of
> identical tables:
>
> The data needs to be arranged as such:
>
> Company 1 item 1 subitem 1
> subitem 2
>
> item 2 subitem A
> subitem B
>
>
> all data comes from a single table, and the above all represent
> individual rows. So in the db, Company 1 would be in all rows, item 1
> would be in the rows of the two subitems, etc. I'm assuming I could
> get those fields to not repeat by using 'Distinct.'
>
> What I'm having a problem with is that the above would be within 1
> table, with its own set of column labels and bordering. And then
> additional identical tables would follow for Company 2, Company 3, etc.
> (actually, it is a little more complicated because each Company table
> has to be sub-divided with different categories of items. But I
> suspect the solution will be within the same concept)
>
> How do I get php to create a separate table for each Company? I am
> very used to using 'while' loops to populate tables. But usually when
> I do this I just create separate tables for separate queries. I'm not
> certain of the way to do the loop so for every Company a separate table
> starts.
>
> I don't need the full coding, I just need to be pointed in the right
> direction.
>
> Thanks!


I think I might have figured this out after posting it. Would the way
to do this be to run queries within the while loop? Something like
this (rough)

query = "select company from table";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$company = $row['company'];

$display .= "<table><tr><td>company</td></tr>";

$get_items_sql = "select item from where company =$company";
$get_itmes_result = mysql_query($query);

while ($row1 = mysql_fetch_array($get_items_result))
{
$item = $row1['item'];

$display .= "<td>item</td>";
-------------

and then another while loop for subitems.

I'll test this out. But if anyone has any feedback, that would be
helpful.

Thanks.

 

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

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