开发者

simple php function

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜