In the if…else statement, if the condition is true it prints a certain code, if its false it prints a different code - is there anyway you can have multiple conditions instead of just one? Here’s an example:
if ($c=="White"){
echo "Your phone is not black";
}else{
echo "Your phone is not white";
}
Is it possible to have all in one if…else statement? ($c==“White” && $m==“Blackberry” && $s==“Verizon”)? If so, how would you do that, using && just returns errors and having more than one “if” line also shoots errors?
if(($c==‘White’) and ($m==‘Blackberry’) and ($s==‘Verizon’)){
echo “Do something here one”;
}elseif (($c==‘Black’) and ($m==‘Blackberry’) and ($s==‘Verizon’)){
echo “Do something here two.”;
}else{
echo “Does not match.”;
}
<?php
if(isset($_POST['color'])){
$c=$_POST['color'];
$m=$_POST['model'];
if ($c=="White" and $m=="Blackberry"){
echo "Your phone is a white blackberry";
}else{
echo "Your phone is not a white blackberry";
}
}
?>
Displays the form/drop down lists like its supposed to but when you select something and click submit nothing happens. That’s the current problem I am having.
If I use the code that savister provided it will display the text, but it will display it before someone clicks submit AND it will not change no matter what you select.
Okay hold on there. Lets wind back to your HTML here a second…
You’ve got two distinct <form>'s there. When you submit one, it only submits the input fields in between it’s <form> and </form> tag. Meaning it submitted the Model information, but not the Color.
So lets make it one nice big form. I’ll even move your submit tag into the right spot
<?php
if(isset($_POST['color'])){
$m=$_POST['model'];
$c=$_POST['color'];
$s=$_POST['service'];
if ($m=="iPhone 1st Generation" and $c=="Black" and $s=="ATT"){
echo "You have a Black iPhone 1 on the ATT Network";
}
}
if ($m=="iPhone 3G" and $c=="White" and $s=="ATT"){
echo "You have a White iPhone 3G on the ATT Network";
}
?>