Results 1 to 15 of 18
Thread: php show image if exist
-
February 18th, 2006, 01:48 AM #1
php show image if exist
using php how would i check to see if a image exist if so output it if not dont?
-
February 18th, 2006, 01:53 AM #2
-
February 18th, 2006, 04:33 PM #3
not working
Originally Posted by nokrev
-
February 18th, 2006, 04:34 PM #4
-
February 18th, 2006, 06:15 PM #5
ok what i am trying to do is show an image that sits inside a table and if there is no image then dont show the table.
do i put the "file_exists" code in the query or before the table?
-
February 18th, 2006, 06:20 PM #6
Nokrev dont he need the \"
so it would be
<?php if (file_exists('filename.jpg')) echo '<img src=\"filename.jpg\" alt=\"File\" title=\"File\" />'; ?>Member #2 of the "I wont critique Timmytot's designs anymore" club.
-
February 18th, 2006, 06:27 PM #7
No. When using different style quotes (single vs. double), they're unnecessary. Additionally, double quotes should be used rarely in PHP, because they're much slower and attempt to parse variables. It's faster to concatenate a variable to a single-quote string than to have one string with an embedded variable.
As for james' problem, you need to encapsulate the entire table inside the check for the image:
PHP Code:<?php if (file_exists('image.jpg')) { ?>
<table><stuff></stuff><stuff><img src="image.jpg" title="My image" alt="My image" /></stuff><stuff /></table>
<?php } ?>
-
February 18th, 2006, 09:11 PM #8Well either way would worlk, my way was correct, wasnt be all means the fastest way, but it would ahve done the job
Originally Posted by nokrev
Member #2 of the "I wont critique Timmytot's designs anymore" club.
-
February 18th, 2006, 10:00 PM #9You stated that you believed the escape slashes were necessary, which implies that it wasn't an alternative method and that it was a working method whereas nokrev's was 'not'. This could be compared to using:
Originally Posted by Seb Hughes
Both of these would work, however, it is probably obvious which one most people would suggest implementing in real life. If you had suggested your method before nokrev had, the 'alternate' method reason would have seemed more acceptable.PHP Code:if(1+1==2){
echo "True";
}
//Instead of:
if(((((((((((1+1))))))))))== 2){
echo "Also True";
}
AS4 expert.
-
February 18th, 2006, 10:07 PM #10
-
February 18th, 2006, 11:56 PM #11
hi well it works in part but it hides both images. Here where it is going:
PHP Code:<?php if (file_exists('$blogimg')) { ?>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="7">
<img src="images/frame_topleft.gif" width="7" height="7" alt="" border="0"><br>
</td>
<td width="10" background="images/frame_toptile.gif">
<img src="images/trans.gif" width="1" height="7" alt="" border="0"><br>
</td>
<td width="7">
<img src="images/frame_topright.gif" width="7" height="7" alt="" border="0"><br>
</td>
</tr>
<tr>
<td width="7" background="images/frame_lefttile.gif">
<img src="images/trans.gif" width="1" height="1" alt="" border="0"><br>
</td>
<td width="10" bgcolor="#DDE9F4">
<img src="images/<?=$blogimg?>.jpg" width="450" height="150" alt="" border="0"><br>
</td>
<td width="7" background="images/frame_righttile.gif">
<img src="images/trans.gif" width="1" height="1" alt="" border="0"><br>
</td>
</tr>
<tr>
<td width="7">
<img src="images/frame_botleft.gif" width="7" height="7" alt="" border="0"><br>
</td>
<td width="10" background="images/frame_bottile.gif">
<img src="images/trans.gif" width="1" height="1" alt="" border="0"><br>
</td>
<td width="7">
<img src="images/frame_botright.gif" width="7" height="7" alt="" border="0"><br>
</td>
</tr>
</table>
<?php } ?>Last edited by james182; February 20th, 2006 at 02:15 AM.
-
February 20th, 2006, 02:17 AM #12
any idaes???
-
February 20th, 2006, 05:47 AM #1370I love PHP & MySql too.
postsPHP Code:<?php echo '<img src='images/$blogimg.jpg' width='450' height='150' alt='' border='0'>'; ?>
-
February 20th, 2006, 11:26 PM #14
After decifering your code, I think this is what you want:
You definitally had it set up pretty screwyPHP Code:<?php
// blogimg should be something like this:
// imagename.jpg
if (file_exists("images/".$blogimg)) {
?>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="7">
<img src="images/frame_topleft.gif" width="7" height="7" alt="" border="0"><br>
</td>
<td width="10" background="images/frame_toptile.gif">
<img src="images/trans.gif" width="1" height="7" alt="" border="0"><br>
</td>
<td width="7">
<img src="images/frame_topright.gif" width="7" height="7" alt="" border="0"><br>
</td>
</tr>
<tr>
<td width="7" background="images/frame_lefttile.gif">
<img src="images/trans.gif" width="1" height="1" alt="" border="0"><br>
</td>
<td width="10" bgcolor="#DDE9F4">
<img src="images/<?php echo $blogimg; ?>" width="450" height="150" alt="" border="0"><br>
</td>
<td width="7" background="images/frame_righttile.gif">
<img src="images/trans.gif" width="1" height="1" alt="" border="0"><br>
</td>
</tr>
<tr>
<td width="7">
<img src="images/frame_botleft.gif" width="7" height="7" alt="" border="0"><br>
</td>
<td width="10" background="images/frame_bottile.gif">
<img src="images/trans.gif" width="1" height="1" alt="" border="0"><br>
</td>
<td width="7">
<img src="images/frame_botright.gif" width="7" height="7" alt="" border="0"><br>
</td>
</tr>
</table>
<?php } ?>
-Bigmtnskier
Last edited by bigmtnskier; February 20th, 2006 at 11:28 PM.
-
February 20th, 2006, 11:27 PM #15
Similar Threads
-
opens php file when a send variabels
By mattiash in forum Server-Side (PHP, SQL, ASP.NET, etc.)Replies: 4Last Post: February 16th, 2006, 10:19 AM -
help with Senocular's Preload next image gallery!
By cameron_ in forum ActionScript 2 (and Earlier)Replies: 2Last Post: October 22nd, 2005, 03:01 PM -
Liquify Image Tutorial Modification
By Tinuviel in forum Flash IDEReplies: 1Last Post: November 24th, 2004, 09:16 AM -
load image from db via php
By beforedawn in forum Flash IDEReplies: 5Last Post: June 2nd, 2004, 04:57 AM -
Image gallery fading slide show script need with background music
By chanani_s in forum Flash IDEReplies: 2Last Post: November 3rd, 2003, 08:23 PM

Reply With Quote


Bookmarks