I'm trying to compare two variables in my if statement. What I'm wanting to accomplish here is when the user inputs the data, I'm wanting the code to echo "Skylark" if and only if the Series = "D" and the Model Year = "2". If the model year was "3" it would echo something different. Here's my code:
$Series=strtoupper(substr($decode,1,1));
if ($Series == "D" && $ModelYear == "2"){
echo "Skylark<br />";
} elseif ($Series == "D" && $ModelYear == "3"){
echo "Century<br />";
} else {
echo "Invalid<br />";
}
$ModelYear=substr($decode,5,1);
if ($ModelYear == "2"){
echo "197$ModelYear";
} elseif ($ModelYear == "3"){
echo "197$ModelYear";
} elseif ($ModelYear == "4"){
echo "197$ModelYear";
} elseif ($ModelYear == "5"){
echo "197$ModelYear";
} elseif ($ModelYear == "6"){
echo "197$ModelYear";
} elseif ($ModelYear == "7"){
echo "197$ModelYear";
} elseif ($ModelYear == "8"){
echo "197$ModelYear";
} elseif ($ModelYear == "9"){
echo "197$ModelYear";
}else{
echo "This is not a valid Model Year";
}
When the submit button is pressed, the $Series echoes the else statement while the $ModelYear echoes the corresponding elseif statement, which is correct. Does anyone know why the $Series isn't echoing correctly? Can you have two variables in an if statement? If a switch statement would be more appropriate, could someone tell me how to include two variables in it?
Thanks!