Hey all,
I have a releases page where I contantly update the dates of up and coming releases. I have an add release page and an edit release page. The add release page works perfectly, however can't make the edit page echo the exiting date back into the display.
The way I have done the add release is to use the following functions:
function WriteDateSelect($BeginYear = 0,
$EndYear = 0,
$IsPosted = true,
$Prefix = '')
{
if (! $BeginYear)
{
$BeginYear = date('Y');
}
if (! $EndYear)
{
$EndYear = $BeginYear;
}
$Year = $IsPosted
? (int) $_POST[$Prefix . 'Year']
: (int) $_GET[$Prefix . 'Year'];
$Month = $IsPosted
? (int) $_POST[$Prefix . 'Month']
: (int) $_GET[$Prefix . 'Month'];
$Day = $IsPosted
? (int) $_POST[$Prefix . 'Day']
: (int) $_GET[$Prefix . 'Day'];
echo '<select name="', $Prefix, 'Year">
';
for ($i = $BeginYear; $i <= $EndYear; $i++)
{
echo '<option ';
if ($i == $Year)
echo 'selected="yes"';
echo '>', $i, '</option>
';
}
echo '</select>-
<select name="', $Prefix, 'Month">
';
for ($i = 1; $i <= 12; $i++)
{
echo '<option ';
if ($i == $Month)
echo 'selected="yes"';
echo '>', $i, '</option>
';
}
echo '</select>-
<select name="', $Prefix, 'Day">
';
for ($i = 1; $i <= 31; $i++)
{
echo '<option ';
if ($i == $Day)
echo 'selected="yes"';
echo '>', $i, '</option>
';
}
echo '</select>
';
return;
} // End function writeDateSelect()
function GetDateSelectString($IsPosted = true,
$Prefix = '')
{
if ($IsPosted)
{
return (int) $_POST[$Prefix . 'Year']
. '-' . (int) $_POST[$Prefix . 'Month']
. '-' . (int) $_POST[$Prefix . 'Day'];
}
return (int) $_GET[$Prefix . 'Year']
. '-' . (int) $_GET[$Prefix . 'Month']
. '-' . (int) $_GET[$Prefix . 'Day'];
} //End GetDateSelectString()
However when I go to the edit page, I explode the date into 3 variables from the database. $Year, $Month and $Day
I'm not sure how to alter these functions to have the existing values selected.
Help, as always, very much appreciated.
Thanks.