| Index
» Projects
» phpMyEdit
» Forum
» Multiple Joins? More than 2 tables |
 |
bjamn
Joined: 25 Dec 2006
Posts: 5
Posted: 2006-12-27 05:11
Back to top
Reply with quote
|
I am looking for a little help in joining multiple table data. I have 3 tables:
Teachers:
TID - teacher id
TNAME - teacher name
Children:
CID - child id
CNAME - child name
Authorization:
IDX - auto incremented index
TID - teacher id
CID - child id
Can someone give me an example of how to get a listing of all children that are grouped with each teacher if you are given the TID only? Any help would be greatly appreciated.
bJamN
|
fefe64
Joined: 11 Dec 2006
Posts: 13
Posted: 2007-01-24 22:52
Back to top
Reply with quote
|
Hello i have the same problem, did you find an exemple?
Thanks
|
bjamn
Joined: 25 Dec 2006
Posts: 5
Posted: 2007-01-25 01:28
Back to top
Reply with quote
|
I passed data to the AUTH.PHP screen using the persist trick...
Inside the calling program I passed the variable THIS_TID like so:
auth.php?this_tid=123
Then inside the AUTH.PHP at the top:
$this_tid = array_key_exists('this_tid', @$_REQUEST) ? @$_REQUEST['this_tid'] : '';
$opts['cgi']['persist'] = array('this_tid' => $this_tid);
$opts['filters'] = "PMEtable0.tid = '$this_tid'";
I used PMEtable0 because it references the current table (AUTH). The $opt['filters'] processes a filter on the AUTH table with the data passed from the calling program. So, at this point, get all AUTH records with a tid = this_tid.
Now I had to display actual teacher names (even though all the records would have the same teacher). Also, I needed to get the childrens names, because all I have is the child ID (CID) for each AUTH record found. So, first to display the teacher names.
$now_tid = $this_tid;
$opts['fdd']['tid'] = array(
'name' => 'Teacher',
'select' => 'T',
'options' => 'ADR',
'maxlen' => 40,
'sort' => true,
'default' => $now_tid,
'escape' => false
);
$opts['fdd']['tid']['values']['table'] = 'teacher';
$opts['fdd']['tid']['values']['column'] = 'tid';
$opts['fdd']['tid']['values']['description']['columns'][0] = 'tname';
$opts['fdd']['tid']['values']['description']['divs'][0] = ' [';
$opts['fdd']['tid']['values']['description']['columns'][1] = 'tid';
$opts['fdd']['tid']['values']['description']['divs'][1] = ']';
$opts['fdd']['tid']['values']['orderby'] = 'tname';
This code displays the teacher names as a column in the table. Now for the student names:
$opts['fdd']['cid'] = array(
'name' => "Authorized Students",
'select' => 'T',
'maxlen' => 40,
'sort' => true,
'escape' => false
);
$opts['fdd']['cid']['values']['table'] = 'student';
$opts['fdd']['cid']['values']['column'] = 'cid';
$opts['fdd']['cid']['values']['description']['divs'][-1] = '<a href="authteacher.php?cid=';
$opts['fdd']['cid']['values']['description']['columns'][0] = 'cid';
$opts['fdd']['cid']['values']['description']['divs'][0] = '&cname=';
$opts['fdd']['cid']['values']['description']['columns'][1] = 'cname';
$opts['fdd']['cid']['values']['description']['divs'][1] = '">';
$opts['fdd']['cid']['values']['description']['columns'][2] = 'cname';
$opts['fdd']['cid']['values']['description']['divs'][2] = ' (';
$opts['fdd']['cid']['values']['description']['columns'][3] = 'cid';
$opts['fdd']['cid']['values']['description']['divs'][3] = ')</a>';
$opts['fdd']['cid']['values']['orderby'] = 'cname';
This also implores the use of VALUES to display a link that passes a student ID (cid) to another program. I works pretty good.
Hope this helps.
bJamN
|
|
Post new topic
Reply to topic
|
|
|
|