i want to put some fields from my database into select options. Therefore i made a function, nl showProjects. I want to show these options but my form isn't showing that values. I don't know where my mistake is...
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;
}
I want to show it in this way:
<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>
除非您使用的是我从未见过的某种框架,否则您需要echo
结果以使它们在页面上可见。
<?php if(isset($bug)) echo $bug->showProjects(); ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.