Kamala - Debt Consolidation - Loan - Debt Consolidation - Debt Consolidation

PDA

View Full Version : Grouping Form Selections Help


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!

javaongsan
Apr 8th 2009, 5:56 pm
<option value"central locking">
you are missing "="
<option value="central locking">

gobbly2100
Apr 8th 2009, 6:41 pm
Thanks for the reply, I actually saw it after some head scratching.

It is kinda funny how when you focus on learning something new you forget some stuff you knew before without thinking.

Thanks again!