Hi,
On my edit page, I'm using dropdown boxes to select the day, month, and year, that the event date needs changing to.
My problem is, I'm using loops to display the days, but how can I do it so if the loop counter equals the day, the option appears selected on the page. I therefore have an if staement when I'm echoing out the options, and if the counter equals the day, the selected attribute is echoed out into the option, so it appears selected.
However, it does not work, can you help? Here is my code
<?php
$link_id = db_connect();
$query = "SELECT * FROM tblevent WHERE eventID = '$eventid'";
$result = mysql_query($query);
if ($myrow = mysql_fetch_array($result)) {
$startdatevalues = explode("-", $myrow["startdate"]);
$startyear = $startdatevalues[0]; // year
$startmonth = $startdatevalues[1]; // month
$startday = date("d", mktime(0, 0, 0, 0, $startdatevalues[2], 0)); // day
$title = $myrow["eventtitle"];
$description = $myrow["eventdescription"];
}
else {
echo "Sorry, no records were found!";
}?>
<select name="startday">
<?php for ($counter = 1; $counter <= 31; $counter ++)
{
echo "<option='" . $counter . "'"
if ($counter == $startday){
.
echo "selected";
.
}
">" . $counter . "</option>";} ?>
</select>