Novice@PHP Posted May 29, 2010 Share Posted May 29, 2010 Hey everyone hope you're fingers aren't too tired after all your hard days coding. I've just coded a lot of a web application but have hit a dead end in regards of calling an image forward. The code uses a name stored in the database to check for a picutre named the same as what the value is in the databse. The problem is I can't figure out how to get it toc check for and disaply the image. The term "refer" in the code is what I need to be able to add .gif .jpg or .png to. So it can check and display the correct image. <?php if (file_exists("logos/".$product["refer"])) { print "<a target='_BLANK' href='".tapestry_buyURL($product)."'><img border='0' src='".$config_baseHREF."logos/".$product["refer"]."' alt='".$product["name"]."' /></a>"; } else { print " "; } ?> All help is appreciated. Also just to note I'm still a total noob so if my explanation doesn't make much sense I'll be more than glad to hear some advice on what way I should say this and answers any questions. Thanks. Quote Link to comment Share on other sites More sharing options...
ZachMEdwards Posted May 29, 2010 Share Posted May 29, 2010 I don't really understand... Like this? if (file_exists("logos/".$product["refer"].".png")) Quote Link to comment Share on other sites More sharing options...
Novice@PHP Posted May 29, 2010 Author Share Posted May 29, 2010 I don't really understand... Like this? if (file_exists("logos/".$product["refer"].".png")) Yes that's it and the second part where refer appears is like the same? <img border='0' src='".$config_baseHREF."logos/".$product["refer"]."' alt='".$product["name"]."' /> Also I knew it would be hard to understand me. I'm only really new to PHP and knownone of the terminology. I just lern by looking through other peeps code. Thanks. Quote Link to comment Share on other sites More sharing options...
Novice@PHP Posted May 29, 2010 Author Share Posted May 29, 2010 I don't really understand... Like this? if (file_exists("logos/".$product["refer"].".png")) Thank you so much. That's it and working up until the second part where refer appears. Do you know what to put in the line below also? <img border='0' src='".$config_baseHREF."logos/".$product["refer"]."' alt='".$product["name"]."' /> Also I knew it would be hard to understand me. I'm only really new to PHP and know none of the terminology. I just learn by looking through other peeps code. Thanks. Quote Link to comment Share on other sites More sharing options...
ZachMEdwards Posted May 29, 2010 Share Posted May 29, 2010 <img border='0' src='".$config_baseHREF."logos/".$product["refer"].".png' alt='".$product["name"]."' /> Quote Link to comment Share on other sites More sharing options...
shino Posted May 29, 2010 Share Posted May 29, 2010 I would personally use is_file() instead of file_exists() Quote Link to comment Share on other sites More sharing options...
Novice@PHP Posted May 29, 2010 Author Share Posted May 29, 2010 Absolutely awesome. Thank you very much, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.