Hi all,
I have a script to update a users details, within that script I have broken down the day the month and the year. I can echo the day from the following script:
$dbday=$row['dbday'];
$dbmonth=$row['dbmonth'];
$dbyear=$row['dbyear'];
$currentValue = $row['dbday'];
//generate drop down for day
echo '<select name="dbday">';
for ($i=1; $i < 32; $i++)
{
//adds a leading zero if needed
//$lz = strlen($i) == 1 ? '0'.$i : $i;
$lz = str_pad($i, 2, '0', STR_PAD_LEFT);
// check if the value displayed is the one currenlty selected
$checkedStatus = '';
if ($i == $currentValue)
{
$checkedStatus = 'SELECTED';
}
echo '<option value="'.$lz.'" '.$checkedStatus.'>'.$lz.'</option>';
}
echo '</select>';
But can't echo the year from so (it just stays on 1900):
$currentvalue3 = $row['dbyear'];
echo '<select name="dbyear">';
for ($i=1900; $i < 2006; $i++)
{
$lz = strlen($i) == 1 ? '0'.$i : $i;
$checkedStatus = '';
if ($i == $currentValue3)
{
$checkedStatus = 'SELECTED';
}
echo '<option value="'.$lz.'" '.$checkedStatus.'>'.$lz.'</option>';
}
echo '</select>';
Before anyone asks if I take out the leading zero from the year all Iget in the drop down is a list consisting of the number '12.'
Any help- much appreciated,
Thanks,
G