Jump to content


Photo

If there or not there


  • Please log in to reply
6 replies to this topic

#1 SkyRanger

SkyRanger
  • Members
  • PipPipPip
  • Advanced Member
  • 649 posts

Posted 19 June 2006 - 03:44 AM

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?
If you search for it, it may be there.

Ensure you use < > button before inserting code for easy reading.

A wise Lady Guru keeps reminding me if you have a select problem: READ THIS

#2 SkyRanger

SkyRanger
  • Members
  • PipPipPip
  • Advanced Member
  • 649 posts

Posted 19 June 2006 - 03:56 AM

[!--quoteo(post=385510:date=Jun 18 2006, 11:44 PM:name=SkyRanger)--][div class=\'quotetop\']QUOTE(SkyRanger @ Jun 18 2006, 11:44 PM) View Post[/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:

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

If you search for it, it may be there.

Ensure you use < > button before inserting code for easy reading.

A wise Lady Guru keeps reminding me if you have a select problem: READ THIS

#3 SkyRanger

SkyRanger
  • Members
  • PipPipPip
  • Advanced Member
  • 649 posts

Posted 19 June 2006 - 04:18 AM

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

echo "<img src=image/" . ($row['image'] == 'Yes' ? "$image" : "No Image") . "' />";
[/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:


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

If you search for it, it may be there.

Ensure you use < > button before inserting code for easy reading.

A wise Lady Guru keeps reminding me if you have a select problem: READ THIS

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 June 2006 - 04:36 AM

umm..

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

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 SkyRanger

SkyRanger
  • Members
  • PipPipPip
  • Advanced Member
  • 649 posts

Posted 19 June 2006 - 03:16 PM

[!--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) View Post[/div][div class=\'quotemain\'][!--quotec--]
umm..

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

Awsome, thanks, exactly what I needed

If you search for it, it may be there.

Ensure you use < > button before inserting code for easy reading.

A wise Lady Guru keeps reminding me if you have a select problem: READ THIS

#6 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 19 June 2006 - 03:47 PM

Or use the ternary operator correctly:

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

~ D Kuang

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 19 June 2006 - 04:58 PM

or yeah that too, but i figured it would be better to use a code he'd probably understand better :\
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users