Jump to content

file location stored in database retrieval to html


carterlangley

Recommended Posts

Hi guys,

 

I have a file location stored in mysql. when i populate the table i need this file location to be a hyperlink to the file itself, so the visitors can click like a normal link and open the file in word and pdf (both formats stored).

 

example of file location as in db "_private/Incident_Reports/Incident%20-%20Applecross%20-%2017%20December%202010%20-%20Website.doc"

example of php code

echo $row['word_document'];

 

any ideas would be really appreciated.

 

 

 

 

 

Link to comment
Share on other sites

OK, here is the code I have.

 

It is populating the table but I need the last two colums to be hyperlinks to a file and not just the file location. If you go to the site, http://www.highland4x4response.co.uk/incident_log.php you will see what it currently looks like.

 

Here is the code.

 

$quey1="select * from incident_log";

$result=mysql_query($quey1) or die(mysql_error());

echo "<div align=\"center\">";
echo "<table class=\"hovertable\" width=\"100%\">";
echo "<tr>";
echo "<th>event type</th>";
echo "<th>call out by</th>";
echo "<th>call out date</th>";
echo "<th>responders</th>";
echo "<th>location</th>";
echo "<th>report in word</th>";
echo "<th>report in pdf</th>";
echo "</tr>";

while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['event_type'];
echo "</td><td>";
echo $row['client'];
echo "</td><td>";
echo $row['incident_date'];
echo "</td><td>";
echo $row['responders'];
echo "</td><td>";
echo $row['location'];
echo "</td><td>";
echo $row['word_document'];
echo "</td><td>";
echo $row['pdf_document'];
echo "</td></tr>";

}

echo "</table>";

?>

 

Hope this helps?

 

Link to comment
Share on other sites

Is the path for the document in web directory? I mean is it in a directory which is accessible by browser?

 

If yes, you can do some thing like this:

 

while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['event_type'];
echo "</td><td>";
echo $row['client'];
echo "</td><td>";
echo $row['incident_date'];
echo "</td><td>";
echo $row['responders'];
echo "</td><td>";
echo $row['location'];
echo "</td><td><a href='".$siteURL.$row['word_document']."'>Click Here</a>";
echo "</td><td>";
echo "</td><td><a href='".$siteURL.$row['pdf_document']."'>Click Here</a>";
echo "</td></tr>";

}

 

Where $siteURL full web browsable URL of the PDF file. I tried appending the path to the domain you suggested but gave 404 so i assume it is not in web directory in private folder.

 

assuming

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.