Here:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Blah </title>
</head>
<body>
<h2>Number Matcher</h2>
<form method="post" action="script.php">
<label>Please select a number:</label>
<select name="number">
<?php
$numbers = array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten");
for ($counter=0; $counter < sizeof($numbers); $counter++)
{
echo "<option value='$counter'>$numbers[$counter]</option>";
}
echo "</select>";
echo "<input type=submit name=submit value=Submit></form>";
?>
</body>
</html>
script.php:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Blah </title>
</head>
<body>
<?php
$digit = $_POST['number'];
$numbers = array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten");
$numero = array ("Uno", "Dos", "Tres", "Cuatro", "Cinco", "Seis", "Siete", "Ocho", "Nueve", "Diez");
$var = "The number <strong>$numbers[$digit]</strong> is the same as <em><strong>$numero[$digit]</strong></em> in Spanish.";
echo $var;
?>
</body>
</html>
I took out your hidden field, and the for loop surrounding it. Gave the options a value of the for $counter variable. Then in script.php I put both arrays and took the for loop out, then I called the correct array by the $digit post variable.
Bookmarks