Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySql PHP选择下拉列表_Php_Html_Mysql_Drop Down Menu - Fatal编程技术网

MySql PHP选择下拉列表

MySql PHP选择下拉列表,php,html,mysql,drop-down-menu,Php,Html,Mysql,Drop Down Menu,我有以下代码 echo '<table class="bookings">'; while($row = mysql_fetch_array($result)){ //set variables for events $id = $row['CourseDateID']; $begin = $row['CourseStartDate']; $end = $row['CourseEndDate']; $title = $row['CourseTitle

我有以下代码

echo '<table class="bookings">';
while($row = mysql_fetch_array($result)){

//set variables for events
    $id = $row['CourseDateID'];
    $begin = $row['CourseStartDate'];
    $end = $row['CourseEndDate'];
    $title = $row['CourseTitle'];
    $att = $row['Attendees'];
    $venue = $row['CourseLocation'];
    $formatted = date('Y-m-d', strtotime($begin));

    echo '<tr>';
    echo '<td>' . $formatted . '</td>';
    echo '<td>' . $title . '</td>';
    echo '<td>' . '<select>' . '<option>' . $att . '</option>' . '</select>' . '</td>';
    echo ' ' . '<td>' . '<a href="/cal.php?id=' . $id . '&begin=' . $begin . '&end=' . $end . '&title=' . $title . '&att=' . $att . '&venue=' . $venue . '">Add Bookings to Calendar</a>' . '</td>';
    echo '</tr>';
}
    echo '</table>';
echo';
while($row=mysql\u fetch\u数组($result)){
//为事件设置变量
$id=$row['CourseDateID'];
$begin=$row['CourseStartDate'];
$end=$row['CourseEndDate'];
$title=$row['CourseTitle'];
$att=$row['Attendes'];
$VICENT=$row['CourseLocation'];
$formatted=date('Y-m-d',strottime($begin));
回声';
回显“.$formatted.”;
回显“.$title.”;
回显“.”.$att.“.”;
回显“.”;
回声';
}
回声';
我希望
将与会者列为下拉列表,但它会创建一个包含所有与会者姓名的
框,而不是一个下拉列表


希望这是有道理的

假设attendee值是一个CSV列表,例如,
John、Fred、Jane、Mary
,则必须将其分解为一个数组并循环:

while($row = ...) {
    ... start table row+select
    $names = explode(',', $row['Attendees']);
    foreach($names as $name) {
        echo "<option>$name</option>"
    }
    ... end select + table row
}
while($row=…){
…开始表格行+选择
$names=分解(“,”,$row['attendes']);
foreach($name作为$name){
回显“$name”
}
…结束选择+表格行
}

假设attendee值是一个CSV列表,例如,
John、Fred、Jane、Mary
,则必须将其分解为一个数组并在其上循环:

while($row = ...) {
    ... start table row+select
    $names = explode(',', $row['Attendees']);
    foreach($names as $name) {
        echo "<option>$name</option>"
    }
    ... end select + table row
}
while($row=…){
…开始表格行+选择
$names=分解(“,”,$row['attendes']);
foreach($name作为$name){
回显“$name”
}
…结束选择+表格行
}

你肯定需要至少一个循环结构,只是一个建议,jQuery也是一个很好的方法,特别是如果你需要每个与会者动态地使用每个id。

你肯定需要至少一个循环结构,只是一个建议,jQuery也是一种很好的方法,特别是当您需要动态地为每个与会者提供每个id时。

$row['attendes']的内容是什么?是的,$row['attendes']的内容是什么?如果这是一个数组,您必须执行此处描述的操作-抱歉@FuzzyTree
$row['attendes']
只是
$row['Forenames']
$row['names']
Thanks@webcreator25与其描述它是什么,不如发布一个实际内容的示例。i、 e.做
var_dump($row['attendeers'])
并将输出作为与会者发布在这里
GROUP_CONCAT('',Forenames',姓氏)
你是说这个吗?!或者如中所示,
$row['attendes']
输出了什么?!
$row['attendes']
的内容是什么?是的,$row['attendes']的内容是什么?如果这是一个数组,您必须执行此处描述的操作-抱歉@FuzzyTree
$row['attendes']
只是
$row['Forenames']
$row['names']
Thanks@webcreator25与其描述它是什么,不如发布一个实际内容的示例。i、 e.做
var_dump($row['attendeers'])
并将输出作为与会者发布在这里
GROUP_CONCAT('',Forenames',姓氏)
你是说这个吗?!或者如中所示,
$row['attendes']
输出了什么?!没有快乐:/。。。与会者是一组预订的名字和姓氏?!然后是一组记录,如日期、会议、名称,每行包含一个名称?然后,您需要添加更多的逻辑来检测何时在会议之间切换,以及何时适当地开始/结束表/选择。。。与会者是一组预订的名字和姓氏?!然后是一组记录,如日期、会议、名称,每行包含一个名称?然后,您将需要添加更多的逻辑来检测何时在会议之间切换并适当地启动/结束表/选择。