HTML & PHP | Filling a select with a query -


i have function uses mysqli function follows:

public function getprojectoptions() {     $return = "";     $sql = "select `id`, `project_name` `projects`;";     $rs  = static::$link->query($sql);     $return .= '<select class="form-control" name="project">';     while ($result = mysqli_fetch_assoc($rs));     {         $return .= "<option value='" . $result['id'] . "'>" .                      $result['project_name'] . "</option>";     }     $return .= '</select>';     return $return; } 

the purpose of function create options , select used projects on site, know there 4 projects stored in table, not return in function, have done wrong?

edit:

link screen output: (http://i.imgur.com/yiyiheh.png)   link code output: (http://i.imgur.com/rzsuiwq.png)   link code usage: (http://i.imgur.com/4j9rvd7.png) 

(wouldn't let me normal links)

i found problem.

remove semi-colon here

while ($result = mysqli_fetch_assoc($rs));                                          ^ 

that's why it's not throwing error, because it's considered valid syntax.

your loop being stopped/terminated it.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -