Autor Zpráva
table
Profil *
Dobrý horký den,
potřeboval bych poradit jak do následujícího scriptu zakomponovat tuto podmínku.
Čeho chci dosáhnout je, že pokud bude naplněno následující, tak to u výsledku zobrazí (ff).
winortie 5= výhra domácích v prodloužení
winortie 2= výhra hostů v prodloužení
Podmínku mám tuto:
if ($data['winortie'] == 2 || $data['winortie'] == 5) {
        print ' (ff)';
    }
Ale nedaří se mi to do toho scriptu dostat tak aby to bylo funkční poradí někdo?
Zde je script:
<?php


require "settings.php";
 
if (isset($_GET['conf'])) {
    $confid = intval($_GET['conf']);
}
else {
    $confid = 0;
}



// Ziskani dat
$queryscores="SELECT sportsdb_wins.winid, sportsdb_wins.windate, sportsdb_wins.wintime, sportsdb_wins.rf, sportsdb_wins.ra, sportsdb_wins.winner,
    sportsdb_wins.loser, sportsdb_wins.wincomments, sportsdb_wins.field, sportsdb_wins.winortie, sportsdb_teams2.teamname AS winningteam,
    sportsdb_teams.teamname AS losingteam
    FROM sportsdb_wins
    LEFT JOIN sportsdb_teams ON sportsdb_wins.loser = sportsdb_teams.teamid
    LEFT JOIN sportsdb_teams AS sportsdb_teams2 ON sportsdb_wins.winner = sportsdb_teams2.teamid
    LEFT JOIN sportsdb_divs ON sportsdb_teams.teamdiv = sportsdb_divs.divid
    LEFT JOIN sportsdb_divs AS sportsdb_divs2 ON sportsdb_teams2.teamdiv = sportsdb_divs2.divid
    WHERE (sportsdb_divs.conference = $confid OR sportsdb_divs2.conference = $confid OR (sportsdb_wins.winconf = $confid AND (sportsdb_wins.loser = -1 OR sportsdb_wins.winner = -1))) AND sportsdb_wins.winortie != 3";

// Sort by team if specified
if (isset($_POST['teamtosort']) && $_POST['teamtosort'] != 'all') {
    $teamtosort = intval($_POST['teamtosort']);
    $queryscores .= " AND (sportsdb_wins.winner = $teamtosort OR sportsdb_wins.loser = $teamtosort)";
}

$queryscores .= ' ORDER BY winid DESC';
$resultscores=mysql_query($queryscores);
$numscores=mysql_num_rows($resultscores);
$html = "";                    // hlavni HTML zasobnik

// neni nulovy pocet zapasu
if($numscores > 0){

    /* Pouzite promenne */
    $teams = Array();            // ciselnik tymu
    $team_matches = Array();    // vazba tymu na zapas
    $matches = Array();            // zapasy
    $matches_data = Array();    // data zapasu

    for($a = 0; $a < $numscores; $a++){
        
        $data = mysql_fetch_array($resultscores);

        // ciselnik tymu
        $team_matches[$data["winner"]][] = $data["winid"];
        $team_matches[$data["loser"]][] = $data["winid"];

        // zapasy
        $matches["id"][] = $data["winid"];

        $matches_data[$data["winid"]]["winner"] =  $data["winner"];
        $matches_data[$data["winid"]]["loser"] =  $data["loser"];

        // skore zapasu
    
            $matches_data[$data["winid"]]["winner_score"] =  $data["rf"];
            $matches_data[$data["winid"]]["loser_score"] =  $data["ra"];
      
 

        // ciselnik tymu
        if(isset($teams[$data["winner"]]) == false){
            $teams[$data["winner"]] = $data["winningteam"];
        }
        if(isset($teams[$data["loser"]]) == false){
            $teams[$data["loser"]] = $data["losingteam"];
        }
    }

    // abecedni razeni tymu;
    asort($teams);

    // prijatelejsi indexovane pole pro tabulku
    $teams_sorted = Array();

    foreach($teams as $key => $value){
        
        $teams_sorted["id"][] = $key;
        $teams_sorted["name"][] = $value;
    }
   
    // horni radek
    $html .= "<tr style='text-align: center; background-color:#4682B4;'>".PHP_EOL;
    $html .= "<td><a href='http://tabulky.michales.eu'><img width='25' src='http://www.erast-liga.cz/wp-content/uploads//e1p.png'></a></td>".PHP_EOL;
    for($a = 0; $a < count($teams_sorted["id"]); $a++){
        
        $html .= "<th><img title='".$teams_sorted["name"][$a]."' src='[$a].".gif'></th>".PHP_EOL]http://www.michales.eu/img/".$teams_sorted["name"][$a].".gif'></th>".PHP_EOL;
    }
    $html .= "</tr>".PHP_EOL;

    // pro kazdy radek
    for($a = 0; $a < count($teams_sorted["id"]); $a++){

        $html .= "<tr>".PHP_EOL;

        // pro kazdry sloupec
        for($b = 0; $b < count($teams_sorted["id"])+1; $b++){

            $html .= "<td>".PHP_EOL;
            $left_team_id = $teams_sorted["id"][$a];

            // prvni sloupec - jmeno
            if($b == 0){
                $html .= "<strong><img title='".$teams[$left_team_id]."' src='.".gif'></strong]http://www.michales.eu/img/".$teams[$left_team_id].".gif'></strong>";
            }
            
            // kazdy dalsi - vysledek nebo X
            else{
                $upper_team_id = $teams_sorted["id"][$b-1];
                

                // stejne tymy - X
                if($left_team_id == $upper_team_id){
                    
                    $html .= "<img src='.".gif'>".PHP_EOL]http://www.michales.eu/img/".$teams[$left_team_id].".gif'>".PHP_EOL;
                }
                      
                // skore
                else{

                    // spolecene zapasy
                    $common_matches = (array_intersect($team_matches[$left_team_id], $team_matches[$upper_team_id]));
                    $common_matches_id = array_values($common_matches);
           
                    // pokud existuji
                    if(count($common_matches_id) > 0){

                        // pro kazdy zapas
                        for($c = 0; $c < count($common_matches_id); $c++){

                            // id zapasu
                            $match_id = $common_matches_id[$c];

                            // vitez / skore 
                            if($matches_data[$match_id]["winner"] == $upper_team_id){
                                
                                $upper_team_score = $matches_data[$match_id]["winner_score"];
                                $left_team_score = $matches_data[$match_id]["loser_score"];
               
                                if($upper_team_score < $left_team_score){ 
                                $class  = "win";  }
                else{
                                $class = "lose"; }
                            } 
                            else{
                                
                                $upper_team_score = $matches_data[$match_id]["loser_score"];
                                $left_team_score = $matches_data[$match_id]["winner_score"];
             
             if($upper_team_score > $left_team_score){
                  $class  = "lose";
                  }else{
                $class  = "win";} 
   
                            } 
    
    
        
                            $html .= "<div class=\"row\"><span class=\"".$class."\">".$left_team_score."</span>:<span class=\"".$class."\">".$upper_team_score."</span></div>"; PHP_EOL;
            
                        }
                    }

                    // neexistuji - pomlčka
                    else{

                        $html .= "<span style='font-family: Arial; font-size: 11px; color:black;'>-</span>".PHP_EOL;
                    } 
                }
            }
              
            $html .= "</td>";
        }
    }
}
 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Křížová tabulka</title><center>
 
</head>
<body>

<style type="text/css">
body { font-family: Arial; font-size: 11px;}
table { border-collapse:collapse; }
table,th, td { border: 1px solid black; }
.lose { color: red; }
.win { color: green; }
.row { width: 100%; }
</style>
 
<table style="text-align: center; background-color:#ADD8E6;">

   <?php echo $html; ?>

</table>
 
</body>
</html>
table
Profil *
Tak jsem upravil SELECT takto:
$queryscores="SELECT CASE WHEN sportsdb_wins.winortie IN (2,5) THEN 'ff' ELSE '' END AS priznak, sportsdb_wins.winid, sportsdb_wins.windate, sportsdb_wins.wintime, sportsdb_wins.rf, sportsdb_wins.ra, sportsdb_wins.winner,
    sportsdb_wins.loser, sportsdb_wins.wincomments, sportsdb_wins.field, sportsdb_wins.winortie, sportsdb_teams2.teamname AS winningteam,
    sportsdb_teams.teamname AS losingteam 
    FROM sportsdb_wins
    LEFT JOIN sportsdb_teams ON sportsdb_wins.loser = sportsdb_teams.teamid
    LEFT JOIN sportsdb_teams AS sportsdb_teams2 ON sportsdb_wins.winner = sportsdb_teams2.teamid
    LEFT JOIN sportsdb_divs ON sportsdb_teams.teamdiv = sportsdb_divs.divid
    LEFT JOIN sportsdb_divs AS sportsdb_divs2 ON sportsdb_teams2.teamdiv = sportsdb_divs2.divid
    WHERE (sportsdb_divs.conference = $confid OR sportsdb_divs2.conference = $confid OR (sportsdb_wins.winconf = $confid AND (sportsdb_wins.loser = -1 OR sportsdb_wins.winner = -1))) AND sportsdb_wins.winortie != 3";
Po té jsem vložil toto $data['priznak'] na řádek který zobrazuje už přímo výsledky.

$html .= "<div class=\"row\"><span class=\"".$class."\">".$left_team_score."</span>:<span class=\"".$class."\">".$upper_team_score." ".$data['priznak']."</span></div>"; PHP_EOL;
Jak můžete vidět tak zde http://michales.eu/kriz.php?conf=12 mi to (ff) neukazuje ikdyž jsou tam 2 zápasy které jsou s winortie 2 a 5 ovšem zde http://michales.eu/kriz.php?conf=21 je (ff) u všech zápasu ikdyž se vyskytuje v tabulce winortie 2 nebo 5 jen 14x.
Jak jinak to zprovoznit? Už jsem v koncích.
table
Profil *
Takže vyřešeno, řešení bylo v celku snadné.

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: