好的,我有这段代码来回显如果选择了值,我如何在不为每天创建变量的情况下将其用于日期下拉列表?
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"';
}
我想通了,仅供参考,这是我想出的:
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]='';
}
}
}