# Help with If-ElseIf Statement

**URL:** <https://forum.kirupa.com/t/help-with-if-elseif-statement/205627>\
**Category:** programming\
**Created:** [October 31, 2006, 11:56am UTC](https://forum.kirupa.com/t/help-with-if-elseif-statement/205627 "2006-10-31T11:56:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![macanudo\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@macanudo\_1](https://forum.kirupa.com/u/macanudo_1)\
**Post date:** [October 31, 2006, 11:56am UTC](https://forum.kirupa.com/t/help-with-if-elseif-statement/205627/1 "2006-10-31T11:56:21Z")

</div>

Hi Everyone, I’m having issues with an IF - ELSE IF statement executing in PHP 4.0.

I’m passing 5 variables from a form page into an execution page. Only 1 of the 5 variables with contain a value which will be an INT value. I need an IF-ELSEIF statement to be able to parse through the 5 variables to grab the 1 that has a value. That value I was going to set to a different variable so i could use that throughout the execution page.

Here is what I have… the 5 variables are $var1-$var5 and I was trying to set the $var variable to the $var1-5 which contained a value. Currently the code is failing on 4th line ‘} elseif…’

\<?  
if ($var1 \> 0) {  
$var = $var1  
} elseif ($var2 \> 0) {  
$var = $var2  
} elseif ($var3 \> 0) {  
$var = $var3  
} elseif ($var4 \> 0) {  
$var = $var4  
} elseif ($var5 \> 0) {  
$var = $var5  
} else {  
echo “NO variables were selected!”;  
}  
?\>

Thanks for the assistance in advance!
