我只是想知道下面的代码是否是用php/sql中的数据库信息填充下拉列表的最有效方法。
//GET ALL SONGS FROM DATABASE
$query = $dbConn->query("SELECT track_id, track_title FROM track");
echo '<select class="feild" name="songDrop">';//MAKE THE DROPDOWN
echo '<option value="none">Choose the Song to add</option>';
// Loop through the query results, displaying the options one by one
while ($row = $query->fetch_assoc()) {
echo '<option value="'.$row['track_id'].'">'.$row['track_title'].'</option>';
}
echo '</select>';
1条答案
按热度按时间whitzsjs1#
试试这个: