DCM Posted September 26, 2010 Share Posted September 26, 2010 Hello all, I currently have some php code which upon a user clicking a search button connects to a back end posgresql database and outputs the users search results in the form of: Hostname IP Address Operating System -------------------------------------------------------------- HOSTA 1.1.1.1 Windows HOSTB 2.2.2.2 Linux With this i have no problem and it works fine. What i would like to do though is as i have each hostname outputted as a hyperlink, i want to be able to then allow the user upon clicking the hyper link of any given hostname to be presented with a more detailed overview of the information associated with that host, i.e. the page reloads upon the user clicking the hyper link but instead of the previous search results the user is now presented with another HTML form populated by all the information stored in the database specific to that host. I am just a bit confused as to how to track the hostname ect from a user clicking the hyperlink, I realise it is likely to be passed via a session variable but how do i set that from a click event of the hyperlink? Thanks for taking the time to read this, any advice is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/214440-phppostreql-and-hyperlinks/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 26, 2010 Share Posted September 26, 2010 The hyperlink you make for each row of data needs a GET parameter that identifies the row of data. Either use the id from the table or the IP address or the hostname, something that uniquely identifies the correct row. Quote Link to comment https://forums.phpfreaks.com/topic/214440-phppostreql-and-hyperlinks/#findComment-1115886 Share on other sites More sharing options...
DCM Posted September 26, 2010 Author Share Posted September 26, 2010 Hi Thanks for the response. I understand the principle (i think) but would the syntax fit into the below statement? <?php echo "<a href = 'searchpage.php'> ".$hostname."</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/214440-phppostreql-and-hyperlinks/#findComment-1115896 Share on other sites More sharing options...
PFMaBiSmAd Posted September 26, 2010 Share Posted September 26, 2010 echo "<a href = 'searchpage.php?id=$some_var'> ".$hostname."</a>"; $some_var is whatever variable currently holds the unique identifying value you want to use as you are looping through the records from the query. In the searchpage.php code, $_GET['id'] will give you identifying value for whichever link was clicked. Quote Link to comment https://forums.phpfreaks.com/topic/214440-phppostreql-and-hyperlinks/#findComment-1115901 Share on other sites More sharing options...
DCM Posted September 26, 2010 Author Share Posted September 26, 2010 Thank you - that makes perfect sense I will give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/214440-phppostreql-and-hyperlinks/#findComment-1115902 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.