AGuyFawkesMask Posted January 19, 2012 Report Share Posted January 19, 2012 Hi all, I'm currently working on modifying pirep_viewreport.tpl such that not only does it display the submit date and pilot name, but also displays who approved the PIREP and the approval date. I figured that if I could located the action taken by an admin in the phpvms_adminlog table, I could lookup the pilotid for that action, locate the pilot name in phpvms_pilots, and display firstname, lastname. However, when I execute this script on the page, it displays firstname, lastname as: Resource id #59 Resource id #60 Here is the code for the script: <?php $pirepid = $report->pirepid; $adminuserid = mysql_query("SELECT pilotid FROM phpvms_adminlog WHERE message=Approved PIREP #'.$pirepid.'"); $adminfirstname = mysql_query("SELECT firstname FROM phpvms_pilots WHERE pilotid='.$adminuserid.'"); $adminlastname = mysql_query("SELECT lastname FROM phpvms_pilots WHERE pilotid='.$adminuserid.'"); ?> And underneath the script is the echo command: <a href="<?php echo SITE_URL.'/index.php/profile/view/'.$adminuserid?>"><?php echo $adminfirstname.' '.$adminlastname?></a> I'm sure I'm just missing a single line or two. I'm not a pro in php or MySQL by any means, but if someone can point out the flaws here, I'd really appreciate it Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 19, 2012 Moderators Report Share Posted January 19, 2012 Hi all, I'm currently working on modifying pirep_viewreport.tpl such that not only does it display the submit date and pilot name, but also displays who approved the PIREP and the approval date. I figured that if I could located the action taken by an admin in the phpvms_adminlog table, I could lookup the pilotid for that action, locate the pilot name in phpvms_pilots, and display firstname, lastname. However, when I execute this script on the page, it displays firstname, lastname as: Here is the code for the script: <?php $pirepid = $report->pirepid; $adminuserid = mysql_query("SELECT pilotid FROM phpvms_adminlog WHERE message=Approved PIREP #'.$pirepid.'"); $adminfirstname = mysql_query("SELECT firstname FROM phpvms_pilots WHERE pilotid='.$adminuserid.'"); $adminlastname = mysql_query("SELECT lastname FROM phpvms_pilots WHERE pilotid='.$adminuserid.'"); ?> And underneath the script is the echo command: <a href="<?php echo SITE_URL.'/index.php/profile/view/'.$adminuserid?>"><?php echo $adminfirstname.' '.$adminlastname?></a> I'm sure I'm just missing a single line or two. I'm not a pro in php or MySQL by any means, but if someone can point out the flaws here, I'd really appreciate it Thanks in advance! I'm sorry, didn't notice the first line, I think what getting out of your table is the pilotid Quote Link to comment Share on other sites More sharing options...
AGuyFawkesMask Posted January 19, 2012 Author Report Share Posted January 19, 2012 I'm sorry, didn't notice the first line, I think what getting out of your table is the pilotid Thanks for the quick reply, parkho, but yes--I'm looking to get the pilotid. Any ideas? Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted January 19, 2012 Moderators Report Share Posted January 19, 2012 Thanks for the quick reply, parkho, but yes--I'm looking to get the pilotid. Any ideas? Try this $adminuserid = mysql_query("SELECT pilotid, message FROM phpvms_adminlog WHERE message=Approved PIREP #'.$pirepid.'"); Quote Link to comment Share on other sites More sharing options...
AGuyFawkesMask Posted January 20, 2012 Author Report Share Posted January 20, 2012 Try this $adminuserid = mysql_query("SELECT pilotid, message FROM phpvms_adminlog WHERE message=Approved PIREP #'.$pirepid.'"); It's still echoing: Resource id #59 Resource id #60 Any other ideas? I feel like I might be using a wrong command/tag here, specifically with MySQL. Just a thought. Quote Link to comment Share on other sites More sharing options...
AGuyFawkesMask Posted January 20, 2012 Author Report Share Posted January 20, 2012 The final code ended up being: <?php $adminuserid_res = mysql_query("SELECT pilotid FROM phpvms_adminlog WHERE message='Approved PIREP #".$pirep->pirepid."'"); $adminuserid_row = mysql_fetch_assoc($adminuserid_res); $adminuserid = $adminuserid_row['pilotid']; $adminfirstname_res= mysql_query("SELECT firstname FROM phpvms_pilots WHERE pilotid='".$adminuserid."'"); $adminfirstname_row = mysql_fetch_assoc($adminfirstname_res); $adminfirstname = $adminfirstname_row['firstname']; $adminlastname_res= mysql_query("SELECT lastname FROM phpvms_pilots WHERE pilotid='".$adminuserid."'"); $adminlastname_row = mysql_fetch_assoc($adminlastname_res); $adminlastname = $adminlastname_row['lastname']; ?> I forgot that I needed to fetch the data from the query. My mistake! Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted January 20, 2012 Administrators Report Share Posted January 20, 2012 You need to use the API calls for this, it's one line. http://forum.phpvms.net/page/index.html?category=6 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.