Extracting data and displaying by category

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Extracting data and displaying by category

Post by aceconcepts »

Hi,

I have a database that has the following structure:

tblClient: clientId, clientName, dob
tblSite: siteId, siteName
tblAttendees: siteId, clientId
tblEvent: eventId, siteId

My question is: what is the best way to display data from the above tables to like like this:

Site: Chicago | No. of attendees: 5

Client name DOB
Mr Smith 25/04/50
Mr Brown 12/12/25

Site: Shanghai | No. of attendees: 2

Client name DOB
Mr Orange 25/04/50
Mr Pink 12/12/25

Just to clarify the above, i'd like to display each site and then display all the related fields as sub lists of the parent site.

Hope this is clear.

Thanks.

Nick
zell11
Forum Newbie
Posts: 7
Joined: Mon Jun 04, 2007 5:24 pm

Post by zell11 »

best way to do this would be to use tables

Code: Select all

// SQL ETC HERE 
<table>
<tr>
<td> Client Name </td>
<td> DOB </td>
</tr>
<?php
while($data = mysql_fecthobject($results))
{
?>
<tr>
<td><?=$data->clientName ?></td> <- if using mysql_fecthobject() otherwise change the php between <td></td>
<td><?=$data->dob ?> </td>
</tr>
<?php
}
?>
</table>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have a read through the first two threads referenced from Useful Posts.
Post Reply