0

Hey guys,

I am really close with this but can't quite get it right... All I am trying to do is retrieve the users details based on their 'u_id' and display them.

<?php
require ('dbconnect.php');
	$user = $_SESSION['username'];         //Get the users username
	$requestuid = mysql_query("SELECT u_id FROM user_usr WHERE u_username = '$user'");      //Get the users u_id based on their username
	$resultuid = mysql_fetch_assoc($requestuid);
	echo $resultuid['u_id'];          //THIS PRINTS THE USERS ID NO
?>

<table>
	<tr>
		<td>Gender:</td>
		<td>
			<?php 
                                   $request = mysql_query("SELECT u_gender FROM users WHERE u_id = '$resultuid'");  
				$result = mysql_fetch_assoc($request); 
				echo $result['u_gender'];    //THIS DOESN'T PRINT THE USERS GENDER
			?>
		</td>
	</tr>
</table>

In my head this should work, but I can't quite get it. Can anyone see where I'm going wrong?

Many Thanks,
Nonshatter

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by nonshatter
0

Line 6 look correct. but in line 14 you use $resultuid.

To get this working insert a line before line 6 and change the current line 6 and 14 like so:

$ruid = $resultid['u_id'];
echo $ruid;

// line 14:
$request = mysql_query("SELECT u_gender FROM users WHERE u_id = '$ruid'");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.