原始代码可让您选择1个事件。 每个ID都包含车间名称,地点和时间。
$event_hour_details = TT_DB::getEventHours(array(
'event_hours_id' => $event_hour_id,
'user_id' => $user_id,
));
$event_hour_details = $workshop_ids[0][0];
$event_hour_details->column_title
我想选择多个活动 因此,我在JS中创建了一个数组,并将其转换为字符串。 ID从JS(xxx,xxx,xxx,...)发送到PHP,在那里我将其爆炸成一个数组
$workshop_ids = explode(',', $event_hour_id);
foreach ($workshop_ids as $workshop_id){
$event_hour_details = TT_DB::getEventHours(array(
'event_hours_id' => $workshop_id,
'user_id' => $user_id,
));
}
$event_hour_details = $workshop_ids[0][0];??
$event_hour_details->column_title??
如何显示所有事件标题? 抱歉我缺乏知识
更新#2
哦,我以为TT_DB :: getEventHours(array())创建了一个数组。
foreach($workshop_ids as $event_details) {
$event_data .= "Workshop: " . $event_details . "<br />"; }
请给我讲习班ID。 但是使用
foreach($event_hour_details_array as $event_hour_details) {
echo $event_hour_details->column_title."<br>"; }
由于某种原因,该值返回空吗?
更新3
调试代码:
Array
(
[0] => Array
(
[0] => stdClass Object
(
[start] => 09.00
[end] => 17.00
[description_1] => Je sterker voordoen dan je bent?
[description_2] => Vrijdag 18 Oktober
[event_title] => Exoskeletons / VR
[column_title] => Willemen Construct en Eifage Benelux
[booking_count] => 10
[available_places] => 150
[slots_per_user] => 30
[current_user_booking_count] => 0
[current_guest_booking_count] => 0
)
)
[1] => Array
(
[0] => stdClass Object
(
[start] => 09.00
[end] => 17.00
[description_1] => tooltip Tectum
[description_2] => Vrijdag 18 Oktober
[event_title] => ?
[column_title] => Tectum
[booking_count] => 4
[available_places] => 150
[slots_per_user] => 30
[current_user_booking_count] => 0
[current_guest_booking_count] => 0
)
)
)
@Adder Ok找到了打印件:D
答案 0 :(得分:0)
您应该使用数组。 $array[]
表示追加到数组。
看来TT_DB::getEventHours
返回了一个对象数组。我在以下代码中考虑了这一点。
$workshop_ids = explode(',', $event_hour_id);
$event_hour_details_array = array();
foreach ($workshop_ids as $workshop_id){
$event_hour_details_array[] = TT_DB::getEventHours(array(
'event_hours_id' => $workshop_id,
'user_id' => $user_id,
));
}
//for debugging
echo "<pre>".print_r($event_hour_details_array, true)."</pre>";
foreach($event_hour_details_array as $event_hour_details) {
foreach($event_hour_details as $hours) {
echo $hours->column_title." ".$hours->start."-".$hours->end."<br>";
}
}
答案 1 :(得分:0)
请尝试这样做,可能会对您有所帮助: $ data = []; foreach($ workshop_ids为$ workshop_id){ $ abc [] = array( 'name_your_column'=> workshop_id 'name_your_column'=> workshop_id ) }