Log in

View Full Version : Only display link if PDF file exists



jcarr
05-01-2007, 10:31 AM
I have created a results page on my golf club’s website www.forestofgaltres.co.uk/fixtures.htm (http://www.forestofgaltres.co.uk/fixtures.htm)

At the beginning of each month I create links on the results page for that month and upload blank PDF documents in date format (20070430.pdf) to the corresponding links.

After each competition someone at the club uploads the results overwriting my blank templates.

This works, but I was wondering if there is a way of having a link on my results page which is only active or displayed etc if the relative PDF file has been uploaded.

If this is not possible, maybe a pop up message box if the PDF file didn't exsist?

This would save me uploading blank PDF files and look a lot more tidy!

Thank you
John

djr33
05-01-2007, 08:21 PM
<?php
if (file_exists('some.pdf')) {
echo '<a href="some.pdf">some.pdf</a>';
}
else {
echo 'no pdf available';
}
?>

Something like that should work, with a bit more customization.

jcarr
05-04-2007, 09:55 AM
Thanks for the reply - Could you give me a few more tips on this, I've had a search on php but I'm a novice on stuff like this.

Thankyou