gitlez

YA: Simple Date Comparisson WOC

Jun 12th, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.33 KB | None | 0 0
  1. <?php
  2. $stmt1 = "SELECT date FROM fixtures GROUP BY date HAVING COUNT(*) > 1";
  3. $result1 = mysql_query( $stmt1 ) or die('MySQL Qeury Error: ' . mysql_error());
  4. $table = '<table width="525" border="0" cellpadding="40" height="63">' . PHP_EOL;
  5. while( $row = mysql_fetch_assoc($result)){
  6.     $date = $row['date'];
  7.     $sDate = date("D M j Y", strtotime($row['date']));
  8.     $table .= '<tr>
  9.        <td colspan="8" align="left" class="td">
  10.            <b>' . $date . '</b>
  11.        </td>
  12.    </tr>' . PHP_EOL;
  13.     $stmt2 = "SELECT * FROM fixtures WHERE date='{$date}'";
  14.     $result2 = mysql_query($stmt2) or die('MySQL Query Error: ' . mysql_error());
  15.     while( $row2 = mysql_fetch_assoc($result2) ){
  16.         $time = strtotime($row2['time']);
  17.         $first = $row2['firstTeam'];
  18.         $second = $row2['secondTeam'];
  19.         $gameid = $row2['gameId'];
  20.         $real_time = date("H:i", $time);
  21.         $timeMinus1Hour = $time - 3600;
  22.         if(time() < $timeMinus1Hour){
  23.             $table .= '<tr class="big">
  24.                <td width="56" align="left" style="color: #709b52;">
  25.                    <a href="" class="result_hover">results</a>
  26.                </td>
  27.                <td width="182" align="right">
  28.                    <a href="forecast.php?first1=' . $first . '&second1=' . $second . '&game_id=' . $gameid . '" id="fixtures">
  29.                        ' . $first . '
  30.                    </a>
  31.                </td>
  32.                <td width="-31" align="center">
  33.                    <a href="forecast.php?first1=' . $first . '&second1=' . $second . '&game_id=' . $gameid . '" id="fixtures">
  34.                        vs
  35.                    </a>
  36.                </td>
  37.                <td width="-12" align="left">
  38.                    <a href="forecast.php?first1=' . $first . '&second1=' . $second . '&game_id=' . $gameid . '" id="fixtures">
  39.                        ' . $second . '
  40.                    </a>
  41.                </td>
  42.                <td>
  43.                    <a href="forecast.php" id="fixtures">
  44.                        ' . $real_time . '
  45.                    </a>
  46.                </td>
  47.            </tr>' . PHP_EOL;
  48.         }
  49.     }
  50. }
  51. $table .= '</table>' . PHP_EOL;
  52. $table .= '<script type="text/javascript">
  53.    $("#fixtures).click(function (){
  54.        return false;
  55.    });
  56. </script>' . PHP_EOL;
  57. echo $table;
Advertisement
Add Comment
Please, Sign In to add comment