我想将数据库中的一些字段放入选择选项中。因此我做了一个函数,nl showProjects。我想显示这些选项,但我的表单没有显示这些值。我不知道我的错误在哪里......
public function showProjects() {
$db = new Db();
$select = "SELECT project_title FROM tblprojects ORDER BY project_title ASC";
$result = $db -> conn -> query($select);
$option ="";
while ($row = mysql_fetch_assoc($result)) {
$option .= '<option value = "' . $row['project_title'] . '">' . $row['project_title'] . '</option>';
}
return $option;
}
我想以这种方式展示它:
<div class="control-group">
<label class="control-label" for="Bug_Project">Project</label>
<div class="controls">
<select name="Bug_Project" class="span5" >
<?php if(isset($bug)) $bug->showProjects(); ?>
</select>
</div>
</div>