Short intro: I study at a university in denmark, and this semester includes PHP coding. So i've only been working with php for a couple of weeks, and I still run in to basic, stupid problems, as u will probably see, hehe.
Anyway, i come to you asking what mistake i made in the following code:
<?php
$day = range(1, 31);
foreach ($day as $value) {
echo "<option value=\"$value\"";
if ($_POST['day'] == $value) {
echo "selected=\"selected\"";
}
echo ">$value</option>\n";
}
?>
Now, what i'm trying to do: I'm currently working on a reference form for people to fill out on a web page. In this form they should enter their date of birth. And with the code above, as you might see, i'm trying to make the array sticky. However, nomatter what i try, it gives me an error when i test the site (using WAMP server).
Can anyone of you correct my code and shed light over what i did wrong? tried multiple things, nothing worked.
Also, since our teacher is not really any good at teaching, could someone explain me what "selected=\"selected\"" does? She sent out the command in a mail with the comment "just copy paste my code"...
Many thanks!
