Need help with echoing data from $_SESSION to <select>
Posted: Wed Sep 13, 2006 9:41 am
Hello,
I have made a form in form.php where one of the form elements consist of <select> component to select the day of the month.
form.php:
Then, in the blahblah.php BEFORE THE HEADER I store the <option value> in $_SESSION['day'] variable, and also provided a form inside the <body> tag for the user to review their entry:
blahblah.php:
Then, I am confused how to retrieve the selected day and display it in the formTestReview....If you test my code, you'll see that I am totally wrong....because of this here:
I know by doing that, would cause the select options displays all the same selected date...but I don't know how to do the right one.
Please help me to retrieve the selected day in the form.php and display the value in the formTestReview within the <option> tag....thanks.
Chris
I have made a form in form.php where one of the form elements consist of <select> component to select the day of the month.
form.php:
Code: Select all
<?php
<form name="formTest" method="post" action = "blahblah.php">
<select name = "day">
<?php
for ($i = 1; $i < 32; $i++) {
echo "<option value = '$i'>".$i."</option>";
}
?>
</select>
</form>
?>
blahblah.php:
Code: Select all
<?php
$_SESSION['day'] = $_POST['day'];
<form name="formTestReview" method="post" action="submit.php">
<select name = "day">
<?php
for ($i = 1; $i < 32; $i++) {
echo "<option value = '$i'>".$_SESSION['day']."</option>";
}
?>
</select>
</form>
?>
Code: Select all
echo "<option value = '$i'>".$_SESSION['day']."</option>";Please help me to retrieve the selected day in the form.php and display the value in the formTestReview within the <option> tag....thanks.
Chris