php - How to get all fields from two different tables by foreign key -


i have query part of function:

function user_data($memberid){ //pass in memberid info user         $data = array();//data returned         $memberid =(int)$memberid;//creating int input          $func_num_args = func_num_args(); //count number of arguments user data on init.php         $func_get_args = func_get_args();          if ($func_num_args >1) { //if more 1, unset first element of array              unset($func_get_args[0]);              $fields = '`' . implode('`,`', $func_get_args) . '`';   //taking array , converting string             $data = mysql_fetch_assoc(mysql_query("select $fields `member`,`oddjob` `memberid` = $memberid"));                  return $data; 

i call function (user_data) in users profile page shows info them. need able display data table called oddjob.

the memberid primary key in member table. memberid foreign key in oddjob table. oddjobid primary key in oddjob table.

i need edit query above pull fields both tables based on memberid. ive tried:

$data = mysql_fetch_assoc(mysql_query("select $fields `member` inner join `oddjob` on `member.memberid` = `oddjob.memberid` `memberid` = $memberid")); 

but keep getting following error when log users profile page;

warning: mysql_fetch_assoc() expects parameter 1 resource, boolean given

any here great. thanks.

surely tell not use mysql functions, instead use mysqli or pdo. query tho

select *   member m,        oddjob o  m.memberid = o.memberid ,    m.memberid = $memberid 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -