Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-04-2007, 03:12 PM   PM User | #1
ptmuldoon
Regular Coder

 
Join Date: Feb 2005
Posts: 659
Thanks: 5
Thanked 14 Times in 14 Posts
ptmuldoon is on a distinguished road
Using if for non-blank data

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:

Code:
<?php if($custom_rules != " "){ ?>
html to custom link here
<? } ?>
ptmuldoon is offline   Reply With Quote
Old 07-04-2007, 04:07 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Use if (empty($var)) or (if $var > '')
__________________
Fumigator is offline   Reply With Quote
Old 07-04-2007, 07:23 PM   PM User | #3
Leppy
New Coder

 
Join Date: Jul 2007
Posts: 26
Thanks: 1
Thanked 0 Times in 0 Posts
Leppy is an unknown quantity at this point
you can use

PHP Code:
<?php
if($var){
    
// $var is NOT empty
} else {
    
// $var is empty
}
?>
But I like the empty function better
__________________
-
Leppy is offline   Reply With Quote
Old 07-05-2007, 03:56 AM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Quote:
Originally Posted by Leppy View Post
you can use

PHP Code:
<?php
if($var){
    
// $var is NOT empty
} else {
    
// $var is empty
}
?>
But I like the empty function better
That so does not work.
__________________
Fumigator is offline   Reply With Quote
Old 07-05-2007, 11:02 AM   PM User | #5
Leppy
New Coder

 
Join Date: Jul 2007
Posts: 26
Thanks: 1
Thanked 0 Times in 0 Posts
Leppy is an unknown quantity at this point
really? I've tested it in few script and when the var is empty, it is like the var = false, no?
__________________
-
Leppy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:43 AM.


Advertisement
Log in to turn off these ads.