tooNight Posted April 20, 2006 Share Posted April 20, 2006 Just wondering if anbody could point me in the right directionWhat I currently have is list of players what I want to do is make each player a hyperlink to a page with their details on. The hyperlink would be like this [a href=\"http://www.mydomain.com/playerDetails.php?playerID=1\" target=\"_blank\"]www.mydomain.com/playerDetails.php?playerID=1[/a] and it would display the player with playerID 1. I have seen this on lots of sites and would like to know how this is done, can anybody recommend me any tutorials or write me a short script to do this.Would be a great help if somebody could point me in the right direction :D table players:players('playerID,playerName,country,email) Cheers Leon Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 20, 2006 Share Posted April 20, 2006 Overview - retrieve the passed variable, use that to retrieve record from database that matches, display record data[code]$player = $_GET['playerID']; // retrieve passed value// make database connection, select database etc$query = "SELECT * from players WHERE playerID = '$player'";$result = mysql_query($query);etc[/code] Quote Link to comment Share on other sites More sharing options...
tooNight Posted April 21, 2006 Author Share Posted April 21, 2006 Still trying to get this to work can get the list of players [a href=\"http://www.squashcommunities.com/players.php\" target=\"_blank\"]here[/a] with the code below. Just cannot get playerDetails.php to display the player that I have just clicked. Whenever I click on a player it takes me to playerDetails.php but I get the message no such username. Just wondering where I am going wrong?players.php[code]<?phpinclude 'library/config.php';include 'library/opendb.php'; $p2=mysql_query("SELECT users.username, users.playerName FROM users") or die(mysql_error());echo "<ol>";while($row=mysql_fetch_assoc($p2)) {echo "<li><a href=\"playerDetails.php?$row[username]=$row[username]\">$row[playerName]</a></li>\r\n";}echo "</ol>";include 'library/closedb.php'; ?>[/code]playerDetails.php[code]<?phpinclude 'library/config.php';include 'library/opendb.php';$username = $_REQUEST['username'];//this bunch of code will get you the id of the player you are looking for//The following code will get the details from mysql table$sql = "SELECT * FROM users WHERE username='$username'";$query = mysql_query($sql);if (mysql_num_rows($query) > 0) {$row = mysql_fetch_array($query);$name = $row['playerName'];$town = $row['town'];$email = $row['email'];}else { echo "No Such username"; exit; }echo "Player Name: $name <br> Town: $town <br> Email: $email";?> [/code] 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.