Mysql
 sql >> Datenbank >  >> RDS >> Mysql

php mysql zeigt Ergebnisse als Dropdown-Liste an

Angenommen, Sie versuchen lediglich, diese Zeilen in einem Dropdown-Menü wiederzugeben:

$sql = "SELECT quali_code, title FROM `qualifications` ORDER BY title ";
$result = mysql_query($sql, $this->connection);
while($r=mysql_fetch_array($result))
{
$quali_code = $r['quali_code'];
$result_array[$quali_code][] = $r['title'];
}


echo "<select name='x'>";
foreach($result_array as $q_code => $value)
{
    foreach($value as $title) {
    echo "<option value='" . $q_code . "'>" . $title . "</option>";
    }
}
echo "</select>";