If statement with isset?

Posted on 2009-05-02
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!

Question by:Mada123
    LVL 17

    Accepted Solution

    Try this
    <?if(isset($MCol11) && ($MCol11 != "0")){echo "Total";} else {echo "";}?>

    Open in new window


    Author Closing Comment

    Excellent! Works perfectly. Thanks so much for your help!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now