View Single Post
07-16-2005, 09:28 PM
#9
sketchie is offline sketchie
sketchie's Avatar
Status: Senior Member
Join date: Jul 2005
Location:
Expertise:
Software:
 
Posts: 835
iTrader: 1 / 100%
 

sketchie is on a distinguished road

  Old

PHP Code:
if (isset($_POST['submit'])) {
//Country is defined from a form (notice the orginal $_POST[])
$country $_POST['country'];

//array is being created.
$capital=array(
//goes "Country => "Capital" seperated by commas
"England" => "London",
"France" => "Paris"
);
//string replaced is used so the country that's chosen selects from the array where it is the same. Then becomes $capital variable
$capital str_replace(array_keys($capital), array_values($capital),$country);

echo 
$capital
} else {
echo 
'<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
echo 
'<select name="country">';
echo 
'<option>England</option>';
echo 
'<option>France</option>';
echo 
'</select>';
echo 
'<input type="submit" name="submit" value="go!">';
echo 
'</form>';