Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a php variable from a hyperlink's id?

Status
Not open for further replies.

allison31

Technical User
Feb 3, 2011
2
TT

Hello everyone,

I'm creating a document management web application which allows users to search for documents. Document records containing the details of each document is in the SQL database table. The search returns a list of sets of two links like:

1) Result1's Title | View details
2) Result2's Title | View details
etc.

Clicking on the Title downloads the document, and clicking on 'View details' is supposed to take the user to a page that displays all the document's details.

My question is, how can I identify which 'View details' was clicked and so display the details of the appropriate document?
I wondered if I could make the id of the 'View details' hyperlink the primary key of each document and use this somehow, but I'm not sure how that would work.

Any suggestions would be greatly appreciated.



 
I wondered if I could make the id of the 'View details' hyperlink the primary key of each document and use this somehow, but I'm not sure how that would work.

that would be ok. as you get more experienced you may want to make all the keys dynamic for security, but this sounds like a very basic app.

it would work like this

Code:
while ($doc = mysql_fetch_object($result)):
//in doc loop
echo "<li>" . $doc->title ."| <a href=\"myDocumentServer.php?docID=" . $doc->id . "\">View Details</a></li>";
endwhile;
 
Thank you very much, I did something like that and it works fine. But I'm new to php, and was unsure. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top