$useridtofind= 123;
$users=array();
while ($data = mysql_fetch_array ($result))
{
$userid = $data['userid'];
$age = $data['age'];
$gender = $data['gender'];
$dob = $data['dob'];
$users[$userid] => array(
'age'=> $age,
'gender'=> $gender,
'dob' => $dob
)
}
$useridtofind=123;
for($v=0; $v< count($users); $v++)
{
if($users[$v]== $useridtofind)
{
//how to go with grab value of age, gender, dob here?
}
}
Take the 2-minute tour
×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
|
|||
|
You seem to be using the user id as the index of the user in the array. If this is the case, you shouldn't be using a
|
|||
|
You already use the id to index the array. Just use:
EDIT: Added isset check and reduced the number of times referencing the same array element |
|||
|