Jump to content

Recommended Posts

How can I make this function say if $id is a set parameter, use it.  If not, use globals $user_info['uid']?

 

function fetch_user_info_by_id()
{
global $user_info;

$sql =	"SELECT 
			`users`.`id`,
			`users`.`firstname`, 
			`users`.`lastname`, 
			`users`.`username`, 
			`users`.`email`,
			`users`.`gender`, 				
			`users`.`accounttype`,
			`users`.`personalweb`,
			`users`.`guestviews`,
			`users`.`iviews`,
			`users`.`eviews`,
			`users`.`credentials`,
			`users`.`specialties`,
			`users`.`country`, 
			`users`.`city`, 
			`users`.`state`, 
			`users`.`phonenumber`,
			`users`.`dateofbirth` AS `dob`,
			`iQuestions`.`investortype`,
			DATE_FORMAT(`users`.`dateofbirth`,'%D \of %M %Y') AS `dateofbirth`,
			DATE_FORMAT(`users`.`signupdate`,'%D %M %Y') AS `signupdate`,
			SUM(`companies`.`capitalrequested`) AS `totalrequested`,
			SUM(`iQuestions`.`capitalavailable`) AS `totalavailable`
		FROM `users` 
		LEFT JOIN `companies`
		ON `users`.`id` = `companies`.`adminid`
		LEFT JOIN `iQuestions`
		ON `users`.`id` = `iQuestions`.`userid` 
		WHERE `users`.`id` = '${user_info['uid']}'";

$result = mysql_query($sql);

return mysql_fetch_assoc($result);
}

Link to comment
https://forums.phpfreaks.com/topic/236463-quick-function-edit/
Share on other sites

Not sure what you mean but change

function fetch_user_info_by_id()
{
global $user_info;

to

function fetch_user_info_by_id($id = null)
{
global $user_info;

if(is_null($id))
	$id = $user_info['uid'];

 

Next change

			WHERE `users`.`id` = '${user_info['uid']}'";

to

			WHERE `users`.`id` = '$id'";

Link to comment
https://forums.phpfreaks.com/topic/236463-quick-function-edit/#findComment-1215700
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.