Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

if statement with blank field

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
rshandel
Smarty Rookie


Joined: 29 Mar 2009
Posts: 16

PostPosted: Wed Sep 01, 2010 9:39 pm    Post subject: if statement with blank field Reply with quote

I have field in a mysql database and I want to check to see if its blank and having trouble finding the value if its blank.

i used

{if $myfield ne ""} or {if $myfield ne " "} or {if $myfield ne "NULL"} and none them seem to work.

Any suggestions?

Thanks
Back to top
View user's profile Send private message
ChrisFah
Smarty Pro


Joined: 02 Nov 2009
Posts: 158
Location: Traun, Austria

PostPosted: Thu Sep 02, 2010 1:15 pm    Post subject: Reply with quote

Hi,


try the other way round:
Code:

{if ((isset($myfield)) && ($myfiels != ''))} {$myfield}
{else} alternate text for empty field {/if}


Regards, Chris
Back to top
View user's profile Send private message
rshandel
Smarty Rookie


Joined: 29 Mar 2009
Posts: 16

PostPosted: Thu Sep 02, 2010 3:40 pm    Post subject: Reply with quote

Thank, Chris.

Worked like a champ!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP