[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

If statement with isset?

Posted on 2009-05-02
2
Medium Priority
?
332 Views
Last Modified: 2012-05-06
I am having a bit of a problem with some php and would appreciate any help.

I have a int field that may be empty because the person doesn't exist in that table or it may have a 0 because the person exists, but doesn't have any data and mysql entered a 0.

So, I tried this:
<?if($MCol11 == "0"){echo "";} else {echo "Total";}?>

Works great until I run across someone who doesn't exist in the table. The word 'Total' shows up because they don't have a 0.

So, I tried this:
<? if (isset($MCol11)) {echo 'Total';} else {echo '';} ?>

It just reverses the problem.

How do I combine the two so that if the person doesn't exist or has a 0, don't display the word 'Total'?

Thanks for you help!

 
0
Comment
Question by:Mada123
2 Comments
 
LVL 17

Accepted Solution

by:
Thomas4019 earned 2000 total points
ID: 24287207
Try this
<?if(isset($MCol11) && ($MCol11 != "0")){echo "Total";} else {echo "";}?>

Open in new window

0
 

Author Closing Comment

by:Mada123
ID: 31577224
Excellent! Works perfectly. Thanks so much for your help!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question