query($query1) or die("Cannot execute query1"); while ($row1 = $result1->fetch_array()) { $value2 = ''; $mehrfachbelegung = trim(get_parameter(6)); if($mehrfachbelegung == 0){ $query2 = "SELECT reihe, platz FROM gd_verfplaetze WHERE concat(reihe,platz) not in (select concat(reihe,platz) from gd_buchung where tid=$termin and lfd_haushalt!=$row1[lfd_haushalt]) AND reihe not in ('Sonntagschule', 'Vorsonntagschule') order by reihe, platz "; }else{ $query2 = "SELECT reihe, platz FROM gd_verfplaetze WHERE reihe not in ('Sonntagschule', 'Vorsonntagschule') order by reihe, platz "; } $result2 = $db->query( $query2) or die ("Cannot execute query2"); $ln2 = 0; while ($row2 = $result2->fetch_array()){ $inner1[$ln2]['reihe'] = $row2['reihe']; $inner1[$ln2]['platz'] = $row2['platz']; $value2 = $inner1; $ln2++; } $query_name = $db->query("SELECT bid, vorname, nachname FROM gd_buchung WHERE reihe = '' AND lfd_haushalt= $row1[lfd_haushalt] AND tid = $termin ORDER BY bid LIMIT 1"); $row_name = $query_name->fetch_array(); $row1['inner'] = $value2; $row1['tid'] = $termin; $row1['vorname'] = $row_name['vorname']; $row1['nachname'] = $row_name['nachname']; $table_data1[] = $row1; } $smarty->assign('table_data1', $table_data1); } $smarty->assign('action', "$action"); $smarty->display("$template/admin/$templatename"); ?>