/    Sign up×
Community /Pin to ProfileBookmark

[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.

[code=php]
If $custom = (empty) {
$label = (default value)
} else {
$label = $custom
}
[/code]

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

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJan 27.2014 — if ($custom == (empty) )
Copy linkTweet thisAlerts:
@gastooonauthorJan 27.2014 — well yes and no, haha.

When re- reading it now I realize I might have explained this poorly.

If ($custom == (empty) [B]<-- It's here instead of empty, I don't know what to put to get it to realize if it is empty or not.[/B] ) {

$label = "1"

} else {

$label = $custom

}

Just put empty to display what I want.

Hope that clears it up. Cheers!
Copy linkTweet thisAlerts:
@ginerjmJan 27.2014 — 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!
Copy linkTweet thisAlerts:
@gastooonauthorJan 27.2014 — 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! ?
Copy linkTweet thisAlerts:
@ginerjmJan 27.2014 — ??? 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.
×

Success!

Help @gastooon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...