I know you can use the if/elseif to make php compare values

if ( $Quantity != 0){
	 $a = ( $b * $c );
	 
		}
elseif ( $Quantity == 0){ 

$a = ( $b + $c );
	 
		}

but what if you want it to do something only if a field has no value.

if ( $Quantity != ' '){
	 $a = ( $b * $c );
	 
		}
elseif ( $Quantity == 'all other values'){ 

$a = ( $b + $c );
	 
		}

Recommended Answers

All 3 Replies

if(!$variable)
{
}
commented: succinct answer, will provoke a little thought :) in the OP +3

as noelthefish wrote, the elseif is redundant and takes (miniscule) resources to run, the ! means not,
If (not$variable) {do something;}
else {do something else}

Great! This works

Thanks for the input.

Eric

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.