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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking to a pdf from a php generated table 2

Status
Not open for further replies.

peaseblossom

IS-IT--Management
Mar 27, 2007
5
GB
Hi there:
I am writing a php/mySql site that locates stored pdf documents.
There is a lot of data so I have a query that generates an html table from the database, to narrow down the search.Thus the visitor is presented with a table of documents from which to select that required.
I have a field in the table that represents the pdf file (ie the cell reads "1234.pdf" for record 1234, etc.
What I am trying to do is set that field to be a link to the actual pdf file. Setting the href in the row upsets php; does anybody know how to insert a link in a php generated table?
Thanks!
 
To partially answer my own question:
I have used this to return the file, where $file is the text field of the pdf:
echo "<td bgcolor = '#CCFF25'><a href='" . $file . "'>Retrieve File</a></td>";

However, it would be a lot cleverer to NOT use the field "1234.pdf" but instead use the index field and append".pdf" as follows:

echo "<td bgcolor = '#CCFF25'><a href='" . $code.pdf . "'>Retrieve File</a></td>";
However, since the $code already has dots either side then this fails. Can anybody suggest a way of getting a link to read "$code" plus ".pdf" in this way; returning a link to "1234.pdf"?
Thanks!

 
Code:
echo "<td bgcolor = '#CCFF25'><a href=\"$code.pdf\">Retrieve File</a></td>";
 
You could also do:
Code:
echo "<td bgcolor = '#CCFF25'><a href='" . $code [red] . ".pdf '[/red]>Retrieve File</a></td>";

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top