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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -