This topic is locked

pulling another table contents into a list view

3/31/2012 9:12:34 AM
PHPRunner General questions
W
wfcentral author

I have two tables. One is tbl_members (id, names, phone numbers, address). Another table is tbl_positions (id, member_id, position).
In this organization each member has held various positions over the years.
On the list view for the members I would like to pull in the data from tbl_positions for each member and show it as a list.
I tried going the easy route - link the tables together and auto create a link on the member list that says "positions (2)" which you can mouseover or click to see the positions they held. This is too confusing for the users.
Robert

C
cgphp 3/31/2012

Set an alias field for the tbl_members table:

(id, names, phone numbers, address, address as position)


Set the new alias field as Custom for the List page and enter the following code:

$rs = CustomQuery("SELECT position FROM tbl_positions WHERE member_id =".$data['id']);
$value = '';
while($record = db_fetch_array($rs))

{

$value .= $record['position'] . "<br/>";

}