2013-08-28 162 views
0

我想下錯誤循環

September 2013 
- 14/09/2013 | 14:30 | Football | League | Paris - Berlin 
- 14/09/2013 | 19:30 | Volley | Cup | Paris - Barcelona 
- 25/09/2013 | 12:00 | Football | Amical | Paris - Bordeaux 
October 2013 
- 5/10/2013 | 15: 00 | Cup | Paris - Londres 

這是我的代碼

 
$dateQuery = mysql_query("SELECT matches.id, date_debut, date_fin, matches.score, sports.title AS sport, clubs1.title AS recevant, clubs2.title AS visiteur, competitions.title AS competition, matches.description, sexes.title AS sexe 
    FROM matches 
    INNER JOIN sexes ON sexes.id = matches.sexe_id 
    INNER JOIN sports ON sports.id = matches.sport_id 
    INNER JOIN clubs AS clubs1 ON clubs1.id = matches.recevant_id 
    INNER JOIN clubs AS clubs2 ON clubs2.id = matches.visiteur_id 
    INNER JOIN competitions ON competitions.id = matches.competition_id 
     WHERE CURRENT_DATE()<=date_debut 
     ORDER BY date_debut ASC") or die(mysql_error());

while($row=mysql_fetch_assoc($dateQuery)){ 
    print '<b>'.$tIndexed[$row['date_debut'] ][ $row['sport'] ][]=date("d-m-Y",strtotime($row['date_debut'])).'</b><br />'; 

foreach($tIndexed as $sDate => $tIndexedDate){ 

    foreach($tIndexedDate as $sEvenement => $tIndexedEvenement){ 

     foreach($tIndexedEvenement as $sTexte){ 
      $sTexte = $row['recevant'].'-'.$row['visiteur']; 
      print date("H:i",strtotime($row['date_debut'])).' | ' .$row['sport'].' | '.$row['competition'].' | '.$sTexte.' <br />'; 
     } 
    } 
    } 
} 

錯誤的結果顯示

14-09-2013 14:30 | Football | Championnat de France | IOS ORLEANS-CSSM PARIS 14-09-2013 19:30 | Football | Championnat de France | CSSM PARIS-ASLS NANCY 19:30 | Football | Championnat de France | CSSM PARIS-ASLS NANCY 21-09-2013 15:00 | Football | Championnat de France | CSS RENNES-CSSM PARIS 15:00 | Football | Championnat de France | CSS RENNES-CSSM PARIS 15:00 | Football | Championnat de France | CSS RENNES-CSSM PARIS 28-09-2013 19:30 | Football | Championnat de France | CSSM PARIS-CSS RENNES 19:30 | Football | Championnat de France | CSSM PARIS-CSS RENNES 19:30 | Football | Championnat de France | CSSM PARIS-CSS RENNES 19:30 | Football | Championnat de France | CSSM PARIS-CSS RENNES

我希望你能幫助顯示該表向我解決這個問題。

感謝您

+0

那麼,什麼是你的問題? –

+0

他希望顯示的結果如他在問題開始時描述的 – Paddyd

+0

將起始查詢更改爲SELECT distinct(matches.id) – nickle

回答

0

試試這個

$dateQuery = mysql_query("SELECT DISTINCT matches.id, date_debut, date_fin, matches.score,  sports.title AS sport, clubs1.title AS recevant, clubs2.title AS visiteur, competitions.title AS competition, matches.description, sexes.title AS sexe 
FROM matches 
INNER JOIN sexes ON sexes.id = matches.sexe_id 
INNER JOIN sports ON sports.id = matches.sport_id 
INNER JOIN clubs AS clubs1 ON clubs1.id = matches.recevant_id 
INNER JOIN clubs AS clubs2 ON clubs2.id = matches.visiteur_id 
INNER JOIN competitions ON competitions.id = matches.competition_id 
    WHERE CURRENT_DATE()<=date_debut 
    ORDER BY date_debut ASC") or die(mysql_error());