If.....Then
Posted: Sat Jul 17, 2004 12:18 am
Yeah its me again with another problem, im programing and I come to a bump in the road although I think it requires an 'if' statement
Right there is a drop down menu (with an attempted if statement) where you can chose weather the server is to be public or private, I have this script (with some other information) outputting onto another page called "getPrice.php". But when I output the information I dont what to know weather the server is public or private I want to know how much it is going to cost the actuall numerical value, at the top of the script I have 2 variables one $pubPrice and the other $prvPrice (which stand for the public price and private price obviousally) and are set to 3 and 2 dollars. Basically this is where my thoughts come in.
I think I need an 'if' statement saying that if the option of the drop down menu equals "Public Server" then send and output the value "$pubPrice" and if the option equals "Private Server" then send and output the value "$prvPrice".
I think my thinking might be on the right track, but I have the slightest clue on the syntax as you see from my attempt
Code: Select all
<?php
//Function determines weather or not the server is to be public or private
print "Choose weather your server is public or private, private servers require passwords to join:";
print "<br><select name="pubOrPiv">
<option>Public Server
</option>
<option>Private Server
</option>
</select>";
if ($pubOrPiv == Public Server) {
$value = $pubPrice;
} else if ($pubOrPiv == Private Server) {
$value = $prvPrice;
} //end if
print "<br><br>";
//END
?>I think I need an 'if' statement saying that if the option of the drop down menu equals "Public Server" then send and output the value "$pubPrice" and if the option equals "Private Server" then send and output the value "$prvPrice".
I think my thinking might be on the right track, but I have the slightest clue on the syntax as you see from my attempt