Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem Zakomponování funkce (php)

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='/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='/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='/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='/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" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="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>
Jsou zobrazeny jen nové odpovědi. Zobrazit všechny
Předmět Autor Datum
Tak jsem to vyřešil. Řešení bylo nakonec jednoduché. poslední
Gizzer 22.06.2013 11:20
Gizzer

Zpět do poradny Odpovědět na původní otázku Nahoru