Jump to content

PHP/postreQL and Hyperlinks


DCM

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.