Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'config.php';
- startMySQLConnection();
- ?>
- <?php
- function get_matches_by_date() {
- $league = $_GET["league"];
- $fd = $_GET["fd"];
- $td = $_GET["td"];
- // $league = 2;
- // $fd = strtotime("02-05-2012");
- // $td = strtotime("14-05-2012");
- $sql = "
- SELECT
- matches.id AS id,
- homeTeam.id AS homeTeamId,
- homeTeam.name AS homeTeamName,
- guestTeam.id AS guestTeamId,
- guestTeam.name AS guestTeamName,
- startDateTime AS matchDate,
- channels.id AS channelId,
- channels.name AS channelName,
- matches.homeTeamGoals,
- matches.guessTeamGoals AS guestTeamGoals,
- stadiums.id AS stadiumId,
- stadiums.name AS stadiumName,
- leagues.id AS leagueId,
- leagues.name AS leagueName,
- rounds.id AS roundId,
- rounds.name AS roundName
- FROM `matches`
- LEFT JOIN leagues ON leagues.id = leagueId
- LEFT JOIN teams AS homeTeam On homeTeam.id = matches.homeTeamId
- LEFT JOIN teams AS guestTeam ON guestTeam.id = matches.guessTeamId
- LEFT JOIN rounds ON rounds.id = rounds.id
- LEFT JOIN channels ON channels.id = channelId
- LEFT JOIN stadiums ON stadiums.id = stadiumId
- WHERE matches.roundId = rounds.id
- AND matches.channelId = channels.id
- AND matches.stadiumId = stadiums.id
- AND matches.leagueId = $league
- AND matches.startDateTime >= $fd
- AND matches.startDateTime <= $td";
- ;
- $result = mysql_query($sql);
- // echo $sql; echo "<br>";
- while ($row = mysql_fetch_array($result)) {
- //tran dau chua dien ra
- if ($row['matchDate'] > time()) {
- $row['homeTeamGoals'] = -1;
- $row['guestTeamGoals'] = -1;
- }
- $output[] = $row;
- }
- print json_encode($output);
- }
- get_matches_by_date();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment