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. Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/ 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")) Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/#findComment-1065148 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. Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/#findComment-1065156 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. Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/#findComment-1065159 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"]."' /> Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/#findComment-1065161 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() Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/#findComment-1065167 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, Link to comment https://forums.phpfreaks.com/topic/203306-im-almost-there-yipee-but/#findComment-1065169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.