Jump to content

Profile Links Echoing


ChidoriSoul
 Share

Recommended Posts

Hey! I am trying to create a view_profile system, and I am having a bit of trouble making where it says:view_profile.php?id=1I need to figure out how to make the ending where it shows the information based on the user information on the link.Can anyone help me?

Link to comment
Share on other sites

view_profile.php?id=1on the view_profile.phpif($_GET['id']){$query = mysql_query("SELECT * FROM `users` WHERE `id` = '$_GET[id]'");$array = mysql_fetch_array($query);print "$array['username']";}else{print "No such user.";}does this solve your problem?

Link to comment
Share on other sites

IT does, but I get this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/pokemonplanet.awardspace.info/view_profile.php on line 12

Line 12 is : Print "$array['name']";

Link to comment
Share on other sites

Oh, well, on the view_profile.php page, you can use the querystring var to select the user's record from the database, and displays the information:

$id = (int) $_GET['id'];$result = mysql_query("SELECT * FROM users WHERE id = $id");$user = mysql_fetch_assoc($result);echo "<h1>{$user['name']}</h1>";echo "<p>This user is {$user['age']} years old.</p>";///etc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...