为此,您要遍历查询结果的每一行,并将此信息用于下拉菜单的每个选项。您应该能够轻松调整以下代码,以满足您的需求。
// Assume $db is a PDO object$query = $db->query("YOUR QUERY HERE"); // Run your queryecho '<select name="DROP DOWN NAME">'; // Open your drop down box// Loop through the query results, outputing the options one by onewhile ($row = $query->fetch(PDO::FETCH_ASSOC)) { echo '<option value="'.$row['something'].'">'.$row['something'].'</option>';}echo '</select>';// Close your drop down box
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)