Ok i have this code to echo the if the values are selected how can i use this for a date dropdown list without creating a variable for each day?
if ($st_title[$i] == 'Mr') {
$mr_select='selected="selected"';
$mrs_select='';
$ms_select='';
} else if ($st_title[$i]=='Mrs') {
$mr_select='';
$mrs_select='selected="selected"';
$ms_select='';
} else {
$mr_select='';
$mrs_select='';
$ms_select='selected="selected"';
}
I figured it out and just for reference here’s what I came up with:
for ($x=0; $x<=31; $x++){
$dobd[$x]='';
if ($x ==$st_dobd){
$dobd[$x]='selected="selected"';
}else{
$dobd[$x]='';
}
}
for ($x=0; $x<=12; $x++){
$dobm[$x]='';
if ($x ==$st_dobm){
$dobm[$x]='selected="selected"';
}else{
$dobm[$x]='';
}
}
for ($x=2000; $x>=1970; $x--){
$doby[$x]='';
if ($x ==$st_doby){
$doby[$x]='selected="selected"';
}else{
$doby[$x]='';
}
}
}
You can create an array with your dates and generate drop-down by this array, keys may be days (dates) and values 0 or 1 if selected.