Jump to content

Archived

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

urbandsigns.com

Need help with MySQL Case statements

Recommended Posts

Ok new to PHP. I've done this before with MSSQL but having a hard time in php.

[code]select (case when collectionImg = '' then '' else '<img src=' collectionImg '><br>' end) as collectionImg[/code]

Basically I want it to check to see if there is a collectionImg. If there is, build the html for me, if not do nothing. Everything works except it doesn't display the collectionImg variable. How do I need to format that part (collectionImg) to get it to work?

Share this post


Link to post
Share on other sites
The posted code is SQL, not PHP. So where does PHP come into the frame?

Share this post


Link to post
Share on other sites
$image= "my variable from the sql query"

if ($img<>"") {do this }


Thats pretty much it...a simple conditional statement.


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.