function search_matches()
{
    global $days, $periods;
    $query = "select distinct match_made.*,\n            UNIX_TIMESTAMP(match_made.start_date) as start_dateunix,\n            UNIX_TIMESTAMP(match_made.match_made) as match_madeunix,\n            student.name,tutor.name\n            from match_made, student, tutor, tutor_request, match_time\n            where match_made.request_id = tutor_request.id\n            and tutor_request.student_id = student.id\n            and match_made.tutor_id = tutor.id\n            and match_made.id=match_time.match_id";
    if (($student_id = $_SESSION['student_id']) || ($student_id = addslashes($_REQUEST['student_id']))) {
        $query .= " AND student_id={$student_id}";
    }
    if (($tutor_id = $_SESSION['tutor_id']) || ($tutor_id = addslashes($_REQUEST['tutor_id']))) {
        $query .= " AND tutor_id={$tutor_id}";
    }
    $active = addslashes($_REQUEST['active']);
    if ($active != NULL) {
        $query .= " AND active={$active}";
    }
    $avail = get_avail();
    if (count_times($avail)) {
        $query .= " AND (";
        $count = 0;
        foreach ($days as $day) {
            foreach ($periods as $period) {
                if ($avail[$day][$period]) {
                    if ($count++ > 0) {
                        $query .= "OR ";
                    }
                    $query .= " (day = {$day} AND period = {$period}) ";
                }
            }
        }
        $query .= ")";
    }
    $query .= " ORDER BY start_date desc";
    $DB = new DB();
    $result = $DB->query($query);
    $results = array();
    while ($row = mysql_fetch_assoc($result)) {
        array_push($results, $row);
    }
    return $results;
}
Example #2
0
    //var_dump($url);exit;
    $opts = array('http' => array('method' => "GET", 'header' => "Content-Type: text/html; charset=utf-8"));
    $context = stream_context_create($opts);
    $response = '';
    while (!$response) {
        $response = file_get_contents($url, false, $context);
    }
    return $response;
}
//////////////////////////////////////////////////
date_default_timezone_set('asia/tehran');
///////////////////////////////////////////////////// start
//get_avail('',3,7396);
//get_avail('8/12/2015',2,7399);
get_avail('12/12/2015', 15, 7396);
get_avail('12/12/2015', 15, 7405);
function get_avail($startdate = '', $days = 1, $hotel_id)
{
    if (!$startdate) {
        $startdate = date('d/n/Y');
    }
    //read all hotels from hotel_source
    //$select="SELECT * FROM `hotels_source` WHERE `source_id` = 5";
    $select = "SELECT * FROM `hotels_source` WHERE `source_id` = 5 AND hotels_id={$hotel_id} AND `extra_data` != ''";
    //var_dump($select);exit;
    $result = mysql_query($select, connect_db());
    while ($row = mysql_fetch_assoc($result)) {
        //var_dump($row);exit;
        //get contry % city codes
        $city = json_decode($row['extra_data'])->city;
        $country = json_decode($row['extra_data'])->country;