$shifts=sql_select("SELECT * FROM `Shifts` WHERE `RID`=".sql_escape($id)." AND `start` >= ".sql_escape($day_timestamp)." AND `start` < ".sql_escape($day_timestamp+24*60*60)." ORDER BY `start`");
$angeltypes=sql_select("SELECT * FROM `RoomAngelTypes` JOIN `AngelTypes` ON (`RoomAngelTypes`.`angel_type_id` = `AngelTypes`.`TID`) WHERE `room_id`=".sql_escape($id)." AND `count` > 0 ORDER BY `AngelTypes`.`Name`");
if(count($angeltypes)){
foreach($angeltypesas$angeltype){
$shifts_table.='<b>'.$angeltype['Name'].':</b> ';
$entries=sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=".sql_escape($shift['SID'])." AND `TID`=".sql_escape($angeltype['TID'])." ORDER BY `Nick`");