unemployment Posted May 15, 2011 Share Posted May 15, 2011 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); } Quote Link to comment https://forums.phpfreaks.com/topic/236463-quick-function-edit/ Share on other sites More sharing options...
wildteen88 Posted May 15, 2011 Share Posted May 15, 2011 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'"; Quote Link to comment https://forums.phpfreaks.com/topic/236463-quick-function-edit/#findComment-1215700 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.