Web Analytics Made Easy -
StatCounter How do I get an 'If' statement to check if a field is empty? - CodingForum

Announcement

Collapse
No announcement yet.

How do I get an 'If' statement to check if a field is empty?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I get an 'If' statement to check if a field is empty?

    Hi there,

    I'm trying to get an 'if' statement to check if a field has an entry, if the field contains anything then I'd like it displayed, otherwise move on.

    Blank fields default to NULL on my DB.

    What I've done seems logical but doesn't work, I'm sure this is really simple!

    Any help would be appreciated.

    Cheers


    if ($show["listen_track"]=="NOT NULL") {

    printf("%s",$show["listen_track"]);
    }

    else

  • #2
    IMO...
    Code:
    if (!empty($show["listen_track"])) {
    CATdude about IE6: "All your box-model are belong to us"

    Comment


    • #3
      Many thanks!

      Comment


      • #4
        You might want to also trim the variable before checking for emptiness.

        PHP Code:
        $show["listen_track"] = trim($show["listen_track"]);
        if (!empty(
        $show["listen_track"])) {
        //Code

        Comment

        Working...
        X