$tour_id = get_str_index_translation('TourTitle', htmlspecialchars(urldecode($Tour)), $encoding_id); $query = "SELECT * FROM {$tblPref}Agency ORDER BY Agency_ID"; $agencys = $db->selectObjects($query); foreach ($agencys as $index=>$agency) { if ($agency->Tours != "") { $tours = unserialize($agency->Tours); $isset = false; foreach ($tours as $t) { if ($t == $tour_id) { $isset = true; } } } else $isset = false; if (!$isset) { unset($agencys[$index]); } } $tpl->assign("agencys", $agencys); ?>