2017-08-17 168 views
1

我想每週選擇一組遊戲比賽。我怎麼能做到這一點。 它假設從當前時間+7天和-7天顯示來自之前和新遊戲的數據。從當前日期到提前7天和過去7天詢問數據

目前,我有這個

function testFR(){ 
    $DateFrom = new DateTime(); 
    $DateTo = new DateTime(); 
    $DateTo->add(new DateInterval("P7D")); 
    $laMatches = (array)WaterpoloAPICached::call("Matches", "getMatches", Array(
     isset($_GET["SeasonId"]) ? $_GET["SeasonId"] : "", 
     isset($_GET["DepartmentId"]) ? $_GET["DepartmentId"] : "", 
     isset($_GET["ClubId"]) ? $_GET["ClubId"] : "", 
     isset($_GET["TeamId"]) ? $_GET["TeamId"] : "", 
     isset($_GET["PoolId"]) ? $_GET["PoolId"] : "", 
     date_format($DateFrom, 'd-m-Y'), 
     date_format($DateTo, 'd-m-Y'), 
     isset($_GET["RefereeId"]) ? $_GET["RefereeId"] : "",  
    )); 
    // Sort Matches ascending 
     usort($laMatches, function($a, $b) { 
         return stringToUnix($a->Date) - stringToUnix($b->Date); 
     }); 
/* echo "<h6 id='rcorners' style='background-color:#3db7e4; padding: 1rem; color:white;'><strong>Wedstrijden</strong></h6>"; */ 
    echo "<table class='hover'>"; 
    echo "<tbody >";   
    $lnToday = date("d-m-Y", strtotime("+7 days"));      
          $lcCurrent = "";       
     foreach($laMatches as $loMatch) { 
      if(stringToUnix($loMatch->Date) >= $lnToday) { 
       if($lcCurrent != $loMatch->Date) {  
      echo "<thead>"; 
      echo "<tr >"; 
      echo "<th class='text-center'>"; 
      echo "$loMatch->Date</th>"; 
      echo "<th class='text-center'></th>";  
      echo "<th class='text-center'></th>"; 
      echo "<th class='text-center'></th>"; 
      echo "<th class='text-center'>Division</th>"; 
      echo "</tr>";     
      echo "</tr> 
       </thead>";   
        }    
        $lcCurrent = $loMatch->Date;      
      echo "<tr class='text-center'>"; 
       echo "<td >$loMatch->Time</td>"; 
       echo "<td>$loMatch->HomeTeam </td>"; 
       echo "<td><strong><a href='..\match?MatchId=".$loMatch->Id."&Report=".$loMatch->MatchReport."'>$loMatch->ResultHome - $loMatch->ResultGuest </a></strong></td>"; 
       echo "<td> $loMatch->AwayTeam</td>"; 
       echo "<td> $loMatch->DepartmentName</td>"; 
      echo "</tr>"; 
      } 
     }  
     echo "</tbody>"; 
     echo "</table>";   
} 

問題已經解決了!對於那些有類似問題的人...希望這可以幫到你!

+0

正如您所看到的標記已被編輯。這裏沒有jQuery,除非你想把邏輯移動到客戶端 – mplungjan

+0

th Rory!編輯 –

回答

0

你差不多了。您可以像這樣通過程序化方式添加/減去日期時間段:

$lnToday = date("d-m-Y", strtotime("+7 days")); 
+0

thx米蘭我會嘗試的! –

+0

仍然獲得所有遊戲的列表。我究竟做錯了什麼?我編輯了迄今爲止我所擁有的內容。 ..我仍然需要一個有點開始時間結束時間? –

+0

很抱歉聽到這些。 '$ loMatch-> Date'返回什麼? – ishegg

相關問題