function help needed

Started on the old forum in October 2014 · view the original in the archive · old links redirect here

3 replies · 85 views · started 12 years ago · 1 min read

2 participants
rajveer Developer · 104 posts #1

Hello Friends I need help in one function

i want to get user info via id with function

example first if i need just username i have to do is

function username($id)
{
$query = mysql_fetch_array(mysql_query("SELECT username FROM members WHERE id = '$id' ");
$username = $query[0];
}

$user_name = username($id);
echo 'hello $user_name';

but i want to get multiple queries from it

function userinfo($id)
{
$query = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE id = '$id' ");

}

i want to di is get array from that function and show it like if username then select username query via function n show it then show gender and other stuff how will that work please help me ??

just_m3. Developer · 199 posts #3
<?php

function userinfo($id,$param)
{

$query = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE id = '$id' ");

return $query[''.$param.''];

}  

// print gender , id , name etc 
echo userinfo($id,'gender');

echo userinfo($id,'name');

echo userinfo($id,'id');

?>
👍 1
Share

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close