Jump to content

If/Else help - Brand new to PHP


mathisjr

Recommended Posts

Hello, can some help me a bit please?

 

I am trying to check two variables for the presence of a valu and do something different depending on the result. Currently I have:

 

$var = xxx
$var2 = yyy
if(empty($var)) {
    if(empty($var2)) {   echo '';   }
} else {
   echo 'something else';
}

 

It works under these conditions: $var is not empty, $var and $var2 both empty. It does not work when $var is empty but $var2 has value.

 

Can someone assist me please?

 

Thanks,

 

Joe

Link to comment
https://forums.phpfreaks.com/topic/148022-ifelse-help-brand-new-to-php/
Share on other sites

what are you actually cheking for do you need to test for all 4 combiations?

 

I am building at table of recipe instructions (Recipes for tying fishing flies). A user can upload up to 20 steps, each step can have a picture and a description or just one or the other. $var & $var2 represent theses two items. As I build the table for viewing, each echo statement will format the table row differently 1. Both entered, 2. only picture, 3. only the description, 4. neither available so nothing is echoed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.