sugna Posted September 30, 2008 Share Posted September 30, 2008 I'm trying to display detailed user information after clicking on a "View Profile" link. I'm using Smarty to bring the data together. Page Display Name1 - Position1 - Click to View Profile Name2 - Position2 - Click to View Profile Name3 - Position3 - Click to View Profile // Display's All Member Information On One Page function getTrainers() { session_start(); $team = $_GET['team']; //DB Connection Stripped for help $config['db_prefix'] = 'cms_';$conn = mysql_connect($config["db_hostname"], $config["db_username"], $config["db_password"]); if (!$conn) { die("Couldnt connect"); } $link = mysql_select_db($config["db_name"], $conn); $query = "SELECT * FROM " . $config["db_prefix"] . "users WHERE job > 0 AND team='$team' AND active='1' ORDER BY job ASC"; $result = mysql_query($query); $res2 = mysql_query("SELECT * from teams WHERE ID='$team'"); $teamImage = mysql_result($res2, 0, "Image"); $teamName = mysql_result($res2, 0, "Name"); print "<div class='teamLogo'><img src='images/team_logos/$teamImage'><br><h1>$teamName</h1></div>"; print "<div class='thinLine'></div>"; while($row = mysql_fetch_array($result)) { print "<div class='member-row'>"; print "<div class='member-name'>" . $row['first_name'] . " " . $row['last_name'] . "</div>"; $nQuery = "SELECT * FROM teams WHERE ID='" . $row['team'] . "'"; $res = mysql_query($nQuery); $nQuery = "SELECT * FROM positions WHERE ID='" . $row['job'] . "'"; $res = mysql_query($nQuery); $nJob = mysql_result($res, 0, "Position"); print "<div class='member-position'> " . $nJob . "</div>"; print "<div class='member-profile-button'><a href='index.php?page=viewProfile'>View Profile</a></div>"; // I want to click here to display the user's full profile without other members print "</div>"; } } Here is the code that should display users info. It does this however it displays the Logged in user's info. I want to show the record's info that was clicked on. Example: I'm logged in as "Smith" When I click on "Name1 - Position1 - Click to View Profile" it displays "Smith" data I want to display "Name1" data. Here's that I'm using to display a single user data. Can any one help? // Display's a Member's Profile on a page function getViewProfile() { $config['dbms'] = 'mysql'; //DB Connection Stripped for help $config['db_prefix'] = 'cms_'; $conn = mysql_connect($config["db_hostname"], $config["db_username"], $config["db_password"]); if (!$conn) { die("Couldnt connect"); } $link = mysql_select_db($config["db_name"], $conn); $query = "SELECT * FROM cms_users"; $result = mysql_query($query); print "<h2>" . mysql_result($result, 0, "first_name") . " " . mysql_result($result, 0, "last_name") . "</h2>"; } Quote Link to comment Share on other sites More sharing options...
Maq Posted September 30, 2008 Share Posted September 30, 2008 Let me guess Smith is the first record in the table? You're not comparing anything to extract the specific information. So you're always grabbing the first record in the table. You need to pass a variable for whatever link the user clicked... $query = "SELECT * FROM cms_users WHERE user_id = '$some_var'"; Quote Link to comment Share on other sites More sharing options...
sugna Posted October 1, 2008 Author Share Posted October 1, 2008 Thanks Mag for your reply. Yes "Smith" would be the first record in the table. Where would I put the code you suggested. In the page that has the links to view profile or the profile output? In reference to my initial post where would I put the code. //What would the link code look like Here is what I have currently print "<div class='member-profile-button'><a href='index.php?page=viewProfile'>View Profile</a></div>"; viewProfile is using a Smarty tag that pulls from a script page (See first Post) Thanks for your time. Shane Quote Link to comment 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.