php - Insert values from database into select option -


i want put fields database select options. therefore made function, nl showprojects. want show these options form isn't showing values. don't know mistake is...

public function showprojects() {     $db = new db();     $select = "select project_title tblprojects order 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 show in 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> 

unless you're using kind of framework have never seen, need echo results them visible on page.

<?php if(isset($bug)) echo $bug->showprojects(); ?> 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -