...

View Full Version : Using if for non-blank data



ptmuldoon
07-04-2007, 04:12 PM
I have text field in a database that will either be blank (Null) depending upon if the user completes a text area in form.

I'd like to show a link based on that field only if the field has data in it. I had thought this would work, but its not:


<?php if($custom_rules != " "){ ?>
html to custom link here
<? } ?>

Fumigator
07-04-2007, 05:07 PM
Use if (empty($var)) or (if $var > '')

Leppy
07-04-2007, 08:23 PM
you can use


<?php
if($var){
// $var is NOT empty
} else {
// $var is empty
}
?>

But I like the empty function better

Fumigator
07-05-2007, 04:56 AM
you can use


<?php
if($var){
// $var is NOT empty
} else {
// $var is empty
}
?>

But I like the empty function better

That so does not work.

Leppy
07-05-2007, 12:02 PM
really? I've tested it in few script and when the var is empty, it is like the var = false, no?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum