PHP Join issue
Posted: Sun Jun 20, 2010 7:14 pm
Hi I am trying to convert a function that currently will only show a user himself and his subusers. I also need to show that persons parent user. It has to be something simple that I am doing wrong and I have worked on this for a week for over 50 hours. Someone else wrote the script and I am having to rework it since they did the main part backwards. Thanks for any help. Sorry if I post this wrong as I am new to the site.
There is a main user_info table called user that holds all users info
UID, name, owner_id, etc
Then there is a table call tm2apptuser that holds user ids with
telemarketers ids for the telemarketers.
uid, tm_id
There is also a table that keeps up with sub users . I need to pull
the person above so that would be level of '1'
uid, par_id, level
Here is the function that I have
There is a main user_info table called user that holds all users info
UID, name, owner_id, etc
Then there is a table call tm2apptuser that holds user ids with
telemarketers ids for the telemarketers.
uid, tm_id
There is also a table that keeps up with sub users . I need to pull
the person above so that would be level of '1'
uid, par_id, level
Here is the function that I have
Code: Select all
function getSelLeadOwner(){
$data['selOwner']=array();
if(db_value("select TYPE from user where
uid=".q(getFromSession('uid')))=='TELEMARKETER'){
$uid=q(getFromSession('uid'));
$data['selOwner']=db_simple_hash("select tm2apptuser.uid,
user_info.NAME
from tm2apptuser
inner join user_info on user_info.UID=tm2apptuser.uid
where tm_id='$uid'
UNION select u2u.uid, user_info.NAME
from u2u
inner join user_info on user_info.UID=u2u.par_id
where uid='$uid' and level='1'");
$r=db_record("select UID, NAME from user_info where UID=$uid");
$data['selOwner'][$r['UID']]=$r['NAME'];
}else{
$rootAgent=permitted('ADMIN-RIGHTS')?'':getFromSession('uid');
$data['selOwner']=getAgentNetworkList($rootAgent/
*(,nvl($data['bankbranch_id'])*/);//getSelOwner();
};
return $data['selOwner'];
}