Rhubarb Posted October 8, 2007 Share Posted October 8, 2007 Hi, sorry for the newbiness of my question! (learning for 3 days) I am trying to link from a user list where a visitor will click a name on the list and be taken to that persons profile. On the list I am using the following code to create the user ID link which works: print "{$row['userid']}</td><td><a href='profile.php?u={$row['userid']}'>"; But what should I add the my profuile page to make sure that the correct user is identified and shown? Thanks in advance... Quote Link to comment https://forums.phpfreaks.com/topic/72300-php-url-help/ Share on other sites More sharing options...
Perad Posted October 8, 2007 Share Posted October 8, 2007 if you start the profile page with $_GET['u'] You can then search the database and return the details of that specific user. Quote Link to comment https://forums.phpfreaks.com/topic/72300-php-url-help/#findComment-364550 Share on other sites More sharing options...
Rhubarb Posted October 8, 2007 Author Share Posted October 8, 2007 Thanks Perad, But i am obviously missing something. Here is my profile code: <?php //start the session session_start(); //check to make sure the session variable is registered if(session_is_registered('myusername')){ } else{ //the session variable isn't registered, send them back to the login page header( "Location: /php/login.php" ); } $_GET['u']; require("header.php"); $result = mysql_query("SELECT * FROM user") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry print "<table border='1' align='center'><tr><td>Profile For <b></b>"; print $row['fname']; print "<br><br /></td</tr></table>"; echo "<table border='1' bgcolor='#eeeeee' align='center' cellpadding='10' bordercolor='red'>"; echo "<tr><th>First Name</th><th> Last Name</th><th>Age</th></tr>"; echo "<tr><td>"; echo $row['fname']; echo "</td><td>"; echo $row['lname']; echo "</td><td>"; echo $row['age']; echo "</td></tr>"; ?> What have I missed? Quote Link to comment https://forums.phpfreaks.com/topic/72300-php-url-help/#findComment-364560 Share on other sites More sharing options...
Rhubarb Posted October 8, 2007 Author Share Posted October 8, 2007 Can anybody advise on this? Would be much appreciated before I tear both of my remaining hairs out! Quote Link to comment https://forums.phpfreaks.com/topic/72300-php-url-help/#findComment-364610 Share on other sites More sharing options...
trq Posted October 8, 2007 Share Posted October 8, 2007 You need to use $_GET['u'] within a WHERE clause of your query. eg; <?php $user = $_GET['u']; $result = mysql_query("SELECT * FROM user WHERE id = '$user'") ?> Quote Link to comment https://forums.phpfreaks.com/topic/72300-php-url-help/#findComment-364632 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.