开发者

simple php function

开发者 https://www.devze.com 2022-12-16 14:04 出处:网络
I wanna be able to get everything from a signed in user. Like, username, email, msn, and alto more with a function like:

I wanna be able to get everything from a signed in user. Like, username, email, msn, and alto more with a function like:

echo getUserInfo('email');

gets the content of "email". but it does not work, see below:

My function:

function getUserInf开发者_JAVA技巧o($field) {

global $userID;

    $sql = mysql_query("select * from users where id = $userID");
    mysql_result($sql, 0, "$field");

   return $field;

}

Does not work, it outputs whatever i put in the function when i call it


edit fixed it:

$userID = 1;

function getUserInfo($field) {

global $userID;

    $sql = mysql_query("select * from users where id = $userID");
    $pop = mysql_result($sql, 0, "$field");

   return $pop;

}
0

精彩评论

暂无评论...
验证码 换一张
取 消