<select name="QuestionType" data-validation-required-message="Choose the Question Type" class="form-control">
<?php
foreach ($drpquestiontype as $row) {
$QuestionTypeId = $row['QuestionTypeId'];
$QuestionTypeName = $row['QuestionTypeName'];
echo '<option value='.$QuestionTypeId.'>'.$QuestionTypeName.'<option>';
}
?>
</select>
请帮忙
答案 0 :(得分:2)
此行缺少引号。单引号会使您退出echo命令,因此生成的html在value属性周围没有引号。您还在关闭选项标记上缺少斜杠。这样:
echo '<option value='.$QuestionTypeId.'>'.$QuestionTypeName.'<option>';
生成这个:
'<option value=6>Name<option>';
PHP代码应为:
echo '<option value="'.$QuestionTypeId.'">'.$QuestionTypeName.'</option>';