Tom Read Posted January 5, 2011 Share Posted January 5, 2011 Hi. I'm fairly new to PHP/MySQL so bare with me! I have a database in place with team names and players in. Each record has an auto-incrementing ID, a team name, and 5 player names. I have selected all the information from the table and have displayed the team names in a while loop, so it ticks through and displays them all ($row['Team_Name']. Basically, what I can't work out to do is how to make the team names hyperlinks, so that clicking on them goes to a new page where it lists their players. I tried <a href = "$row['Team_Name']"> . $row['Team_Name']; . <?a>, but I think it's a bit more complex than that as that doesn't work! Sorry if some of my syntaxing above is wrong - I'm on a college computer and my code is on my laptop so some stuff above is wrong, but I dare say you'll know exactly what I mean! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/223463-mysql-query-from-db-hyperlink-to-show-record/ Share on other sites More sharing options...
ttocskcaj Posted January 5, 2011 Share Posted January 5, 2011 It's pretty easy, you just have to make a new php script to link to. For example the page that displays the list of teams might be index.php And the one that displays the team players might be team.php That way you can link like echo '<a href = "team.php?team='.$row['Team_Name'].'"> . $row['Team_Name'] . </a> That way the team name is passed to the team.php script via the get method, (notice the ?team= at the end) Then in the next page you can select the row that has that teams details. use this: http://pastebin.com/N8iUViEj as an example. I have to go so I can't write the whole thing for you. Quote Link to comment https://forums.phpfreaks.com/topic/223463-mysql-query-from-db-hyperlink-to-show-record/#findComment-1155435 Share on other sites More sharing options...
ttocskcaj Posted January 6, 2011 Share Posted January 6, 2011 Give this a go, see if you can understand it. http://pastebin.com/L07Lv6XS Quote Link to comment https://forums.phpfreaks.com/topic/223463-mysql-query-from-db-hyperlink-to-show-record/#findComment-1155546 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.