gobbly2100
Apr 8th 2009, 3:32 pm
Hey there,
I am learning some basic PHP but I can't quite understand why this tutorial I am following is not appearing to work.
Here is the code:
<?php
if (!$_POST['submit']) {
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">
<select name="options[]" multiple>
<option value"central locking">Central Locking</option>
<option value"steering lock">Steering Lock</option>
<option value"abs">ABS</option>
<option value"traction control">Traction Control</option>
<option value"remote locking">Remote Locking</option>
</select>
<input type="submit" value="Submit!" name="submit" />
<input type="reset" value="Reset" />
</form>
<?php
}
else {
if (is_array($_POST['options'])) {
echo "<p>Here is your selection</p>";
echo "<ul>";
foreach ($_POST['options'] as $o) {
echo "<li>" . $o . "</li>";
}
echo "</ul>";
}
else {
echo "Nothing Selected";
}
}
?>
I have copied the code from the tutorial so I am a little lost about what is wrong, I just let 2 li tags but no array actually show as text.
I hope someone can help, thank you!
I am learning some basic PHP but I can't quite understand why this tutorial I am following is not appearing to work.
Here is the code:
<?php
if (!$_POST['submit']) {
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST">
<select name="options[]" multiple>
<option value"central locking">Central Locking</option>
<option value"steering lock">Steering Lock</option>
<option value"abs">ABS</option>
<option value"traction control">Traction Control</option>
<option value"remote locking">Remote Locking</option>
</select>
<input type="submit" value="Submit!" name="submit" />
<input type="reset" value="Reset" />
</form>
<?php
}
else {
if (is_array($_POST['options'])) {
echo "<p>Here is your selection</p>";
echo "<ul>";
foreach ($_POST['options'] as $o) {
echo "<li>" . $o . "</li>";
}
echo "</ul>";
}
else {
echo "Nothing Selected";
}
}
?>
I have copied the code from the tutorial so I am a little lost about what is wrong, I just let 2 li tags but no array actually show as text.
I hope someone can help, thank you!