I am working on a real estate website. We are drawing in real estate listings using MLS numbers and some of these listings have PDF brochures. I would like to check if a brochure exists for a listing - the PDF file is "mls#.pdf", with the MLS # matching the listing. If there is a PDF, I want to link to that. Otherwise the link should go to the MLS page for that listing.
I have tried this code below, but I don't know how to set it to search for/link to the filename that matches the listing. (The second echo is clearly wrong too, I don't know how to go back and forth from php in that way).
<?php
$inc_file = "pdf/$MLS_ACCT.pdf";
if (file_exists($inc_file)) {
echo '<a href="pdf/$MLS_ACCT.pdf">Click here for Brochure - Open PDF at 100%</a>';}
else {
echo '<a href="property-search-results.php?MLS_ACCT=<?php echo $MLS_ACCT ;?>" target="_top">Further Details >></a>'; }
?>