Jump to content

Trouble calling admin name in script [SOLVED]


AGuyFawkesMask

Recommended Posts

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!

Link to comment
Share on other sites

  • Moderators

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...