www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] Empty db row, if/else

  1. #1
    Join Date
    Nov 2013
    Posts
    18

    resolved [RESOLVED] Empty db row, if/else

    I'm pretty new to php and I'm trying to figure out the most on my own to learn but been stuck on this problem a little while so decided to ask for help.

    Alright, I got a row in my db named "custom". What I want to do with that is something like this.

    PHP Code:
    If $custom = (empty) {
         
    $label = (default value)
    } else {
         
    $label $custom

    It's probably really easy but haven't be able to find any good resources to help me do it myself.
    Thanks!

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    640
    if ($custom == (empty) )

  3. #3
    Join Date
    Nov 2013
    Posts
    18
    well yes and no, haha.
    When re- reading it now I realize I might have explained this poorly.

    If ($custom == (empty) <-- It's here instead of empty, I don't know what to put to get it to realize if it is empty or not. ) {
    $label = "1"
    } else {
    $label = $custom
    }

    Just put empty to display what I want.
    Hope that clears it up. Cheers!

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    640
    If you are looking for an empty var check for '' (2 single quotes).

    OR - a quick search of the PHP Manual (handy item that) on 'empty' turns up the 'empty' function. Doh!

  5. #5
    Join Date
    Nov 2013
    Posts
    18
    Didn't find anything in php manual. But after a few more hours of digging and trying this was what I were looking for.

    if (!empty($custom)) {

    I were so close haha. But thanks anyways!

  6. #6
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    640
    ??? How can you not find 'empty' in the manual??? I simply typed empty in the search box in the functions section and voila - Empty() came up.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles