I have a little problem here.
I am using the following code to reate a dynamic day, month, and year list starting with today's date.
From this I create three different variables date_day, date_month, and date_year.
I use this code on two pages to both ADD and EDIT entries into the my table.
What I would like to do is change out the code on my EDIT page so that it will call in the information that was previously selected and not return the day, month, and year to the current day.
It makes it a big pain to reset the date every time you edit an entry.
Thanks for any help you can give.
Here is the code for my query.
// generate and execute query
$query = "SELECT id, date_year, date_month, date_day, city, state, venue, venue_web, bill, bill_web, show_info FROM $dbtable WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
And here is the code for my dynamic drop down menu creation.
<table cellspacing="0" cellpadding="5" border="0" bgcolor="#000000" align="center">
<link rel="stylesheet" href="main.css" type="text/css">
<form action="<? echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="id" value="<? echo $id; ?>">
<tr>
<td valign="top" class="text"><b>Date:</b></td>
<td>
<?php
/ create an array of months/
$monthName = array(1=> "January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November",
"December");
$today = Time(); //stores today's date
$f_today = date("M-d-Y",$today); //formats today's date
/ build selection list for the month /
$todayMO = date("m",$today); //get the month from $today
echo "<select name='date_month'>\n";
for ($n=1;$n<=12;$n++)
{
echo "<option value=$n\n";
if ($todayMO == $n)
{
echo " selected";
}
echo "> $monthName[$n]\n";
}
echo "</select>";
/ build selection list for the day /
$todayDay= date("d",$today); //get the day from $today
echo "<select name='date_day'>\n";
for ($n=1;$n<=31;$n++)
{
echo " <option value=$n";
if ($todayDay == $n )
{
echo " selected";
}
echo "> $n\n";
}
echo "</select>\n";
/ build selection list for the year /
$startYr = date("Y", $today); //get the year from $today
echo "<select name='date_year'>\n";
for ($n=$startYr;$n<=$startYr+1;$n++)
{
echo " <option value=$n";
if ($startYr == $n )
{
echo " selected";
}
echo "> $n\n";
}
echo "</select>\n";
?>
</td>
</tr>
</table>