gpt4 book ai didi

php - MySql PHP 选择下拉列表

转载 作者:行者123 更新时间:2023-11-30 22:35:36 24 4
gpt4 key购买 nike

我有以下代码

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>';

我想要 <select>将与会者列为下拉列表,但它会创建一个 <select>包含所有与会者姓名的框,而不是下拉列表。

希望这是有道理的。

最佳答案

假设与会者值是一个 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
}

关于php - MySql PHP 选择下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32632980/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com