我有以下代碼MySql的PHP選擇下拉列表中
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>
列出與會者作爲一個下拉,但ATM它創建了一個<select>
箱在而非下拉列表中的所有參加者的姓名。
希望是有道理的。
'$ row ['Attendees']'的內容是什麼? – FuzzyTree
是的,$ row ['Attendees']的大小是多少?如果這是一個數組,你將不得不做一些這裏描述的內容 - http://stackoverflow.com/questions/23546818/php-foreach-loop-to-populate-dropdown-list-with-values-from-an-array -of-arrays –
對不起@FuzzyTree'$ row ['Attendees']'只是$ row ['Forenames']'&'$ row ['Surname']' 的分組感謝 – webcreator25