Advertisement
gitlez

YA: Simple Date Comparisson WC

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