i want to write a script which show the data from database after choosing the option in selection box.
here is part of my coding:
<form name="form1" method="post" action="untitled.php?sdate=$viewdate">
<?php
// create the selection box - date format
if ($sdate)
{
$vdate = $sdate;
}
else
{
$vdate = date("Y-m-d");
}
$count = 30;
echo "<select name=\"viewdate\">";
for ($i = 0; $i < $count; $i++)
{
$ddate = date("Y-m-d",mktime (0,0,0,date("m"), date("d")+$i, date("Y")));
echo "<option value=\"$ddate\"> $ddate</option>";
}
?>
<input type="submit" name="Submit" value="Submit">
</form>
<br>
// sql statement to retrieve the data (using variable $vdate)
// format the data in table
I can display the data correct first time i go to the page "untitled.php". However, after i choose an option in the selection box and submit. No record can be found. When i display the variable $vdate, it become "$viewdate".
Where is the problem?
😕