Jump to content


Photo

if($row['.....) = nothing?


  • Please log in to reply
4 replies to this topic

#1 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 01 September 2006 - 12:01 PM

How do I use an IF statement to do, if there is NOTHING in the database?

I tried:

if(.....) = 0)

...but it looks for a '0' in the database?

Thanks. :D
~ Mutley.

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 September 2006 - 12:14 PM

Actually you are assing $row['blah'] with zero with the posted code. You use use two equal signs together, or use the empty function to check whether the the variable holds an empty value.
if(empty($row['field_name_here']))
{
    echo 'field_name_here is empty!';
}


#3 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 01 September 2006 - 12:16 PM

It's actually empty, not is_empty ;)
I'm just a guy who likes to code for fun...

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 September 2006 - 12:27 PM

Yeah I correct that when I posted. :)

#5 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 01 September 2006 - 12:28 PM

Thanks, worked a treat. :D
~ Mutley.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users