soullessj Posted June 10, 2011 Share Posted June 10, 2011 Hi I'm wondering if it is possible to query a database for info and then when i get the info such as 'Name' to be able to turn the list of names into a corresponding hyperlink. ie. name 1 name 2 name 3 name 4 name 5 if i were to click name 1 it would send me to a page setup to display name 1 information and if i clicked name 2 it would do the same but show me name 2 information. At the moment i am manually creating the name and hyperlinking it to another page using the $id variable to be carried over into the page and select the info that i want to display from the database. Thanks Link to comment https://forums.phpfreaks.com/topic/238944-database-querying-and-using-hyperlinks-with-the-data/ Share on other sites More sharing options...
soullessj Posted June 10, 2011 Author Share Posted June 10, 2011 im using this command for the hyoer link <a href="http://www.somesite.com/somepage.php?id=1"></a> so that the database query displays the row where the id = 1 Link to comment https://forums.phpfreaks.com/topic/238944-database-querying-and-using-hyperlinks-with-the-data/#findComment-1227819 Share on other sites More sharing options...
dragon_sa Posted June 10, 2011 Share Posted June 10, 2011 you would query the database and then run a while loop to setup your links <?php $sql=mysql_query("SELECT * FROM table"); while ($result=mysql_fetch_array($sql)) { $id=$result['id']; $name=$result['name']; echo "<a href=\"http://www.somesite.com/somepage.php?id=$id\">$name</a><br/>"; } ?> Link to comment https://forums.phpfreaks.com/topic/238944-database-querying-and-using-hyperlinks-with-the-data/#findComment-1227830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.