Jump to content

Archived

This topic is now archived and is closed to further replies.

SkyRanger

If there or not there

Recommended Posts

Here is the situation:

I use to have a piece of code from along time ago that did this for me, but I lost it, can can't remember how I did it.


This is what I need:

mysql garbage

if $image exists echo '$image'
if $image does not exist then echo "No Image"

Can anybody help me with this?

Share this post


Link to post
Share on other sites
[!--quoteo(post=385510:date=Jun 18 2006, 11:44 PM:name=SkyRanger)--][div class=\'quotetop\']QUOTE(SkyRanger @ Jun 18 2006, 11:44 PM) [snapback]385510[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Here is the situation:

I use to have a piece of code from along time ago that did this for me, but I lost it, can can't remember how I did it.
This is what I need:

mysql garbage

if $image exists echo '$image'
if $image does not exist then echo "No Image"

Can anybody help me with this?
[/quote]


Nevermind, found what I was looking for:

[code=php:0]
echo "<img src=image/" . ($row['image'] == 'Yes' ? "$image" : "No Image") . "' />";
[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=385515:date=Jun 18 2006, 11:56 PM:name=SkyRanger)--][div class=\'quotetop\']QUOTE(SkyRanger @ Jun 18 2006, 11:56 PM) [snapback]385515[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Nevermind, found what I was looking for:

[code=php:0]
echo "<img src=image/" . ($row['image'] == 'Yes' ? "$image" : "No Image") . "' />";
[/code]
[/quote]

Ok, thought I had it but I am getting this error:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/low/public_html/roster.phtml on line 167

This is the code I have:


[code]
<? echo "<img src='" . ($row['image'] == 'Yes' ? $image"/>View Image</a>" : "No Image") . "'"; ?>
[/code]

Share this post


Link to post
Share on other sites
umm..

[code]
if ($row['image']) {
   echo "<img src = '" . $row['image'] . "' />";
} else {
  echo "no image";
}
[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=385526:date=Jun 19 2006, 12:36 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 19 2006, 12:36 AM) [snapback]385526[/snapback][/div][div class=\'quotemain\'][!--quotec--]
umm..

[code]
if ($row['image']) {
   echo "<img src = '" . $row['image'] . "' />";
} else {
  echo "no image";
}
[/code]
[/quote]

Awsome, thanks, exactly what I needed

Share this post


Link to post
Share on other sites
Or use the ternary operator correctly:

[code]echo ($row['image']) ? '<img src="' . $row['image'] . '"/>' : 'No Image';[/code]

Share this post


Link to post
Share on other sites
or yeah that too, but i figured it would be better to use a code he'd probably understand better :\

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.