douliu3831 2012-05-16 10:05
浏览 48

SQL查询结果进入下拉列表

I am trying to get the names of the events from a table in a database, i need to insert this data in a dropdown list, so then someone clicks them and then the information for this specific event displays...

Here is my code up to now..

<?php

require "config.php"; // Your Database details 
?>

<?PHP


$SQL = "SELECT title_en_US FROM civicrm_event";
$result = mysql_query($SQL);
// Write out our query.
$query = "SELECT title_en_US FROM civicrm_event";
// Execute it, or return the error message if there's a problem.
$result = mysql_query($SQL);

while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['title_en_US'] . "<BR>";

}

?>

Can you tell me how to put first the event names into a dropdown list?

Thanks!

  • 写回答

1条回答 默认 最新

  • dpaal28266 2012-05-16 10:17
    关注

    Please use the following code

    $options='';
    while($db_field = mysql_fetch_assoc($result))
    {
        $options .= "<option>".$db_field['title_en_US']."</option>";
    } 
    

    For the html part,

    <select name="titles"><? echo $options; ?></select>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致