Zadejte hledaný výraz...

Zakomponování funkce

table
verified
rating uzivatele
20. 6. 2013 11:29:00
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 == 2 || $data == 5) {
print ' (ff)';
}
Ale nedaří se mi to do toho scriptu dostat tak aby to bylo funkční poradí někdo?
Zde je script:
require "settings.php";
if (isset($_GET)) {
$confid = intval($_GET);
}
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) && $_POST != 'all') {
$teamtosort = intval($_POST);
$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;
$team_matches][] = $data;
// zapasy
$matches[] = $data;
$matches_data] = $data;
$matches_data] = $data;
// skore zapasu
$matches_data] = $data;
$matches_data] = $data;
// ciselnik tymu
if(isset($teams]) == false){
$teams] = $data;
}
if(isset($teams]) == false){
$teams] = $data;
}
}
// abecedni razeni tymu;
asort($teams);
// prijatelejsi indexovane pole pro tabulku
$teams_sorted = Array();
foreach($teams as $key => $value){
$teams_sorted[] = $key;
$teams_sorted[] = $value;
}
// horni radek
$html .= "".PHP_EOL;
$html .= "".PHP_EOL;
for($a = 0; $a < count($teams_sorted); $a++){
$html .= "".PHP_EOL;
}
$html .= "".PHP_EOL;
// pro kazdy radek
for($a = 0; $a < count($teams_sorted); $a++){
$html .= "".PHP_EOL;
// pro kazdry sloupec
for($b = 0; $b < count($teams_sorted)+1; $b++){
$html .= "".PHP_EOL;
$left_team_id = $teams_sorted;
// prvni sloupec - jmeno
if($b == 0){
$html .= "";
}
// kazdy dalsi - vysledek nebo X
else{
$upper_team_id = $teams_sorted;
// stejne tymy - X
if($left_team_id == $upper_team_id){
$html .= "".PHP_EOL;
}
// skore
else{
// spolecene zapasy
$common_matches = (array_intersect($team_matches, $team_matches));
$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;
// vitez / skore
if($matches_data == $upper_team_id){
$upper_team_score = $matches_data;
$left_team_score = $matches_data;
if($upper_team_score < $left_team_score){
$class = "win"; }
else{
$class = "lose"; }
}
else{
$upper_team_score = $matches_data;
$left_team_score = $matches_data;
if($upper_team_score > $left_team_score){
$class = "lose";
}else{
$class = "win";}
}
$html .= "
".$left_team_score.":".$upper_team_score."
"; PHP_EOL;
}
}
// neexistuji - pomlčka
else{
$html .= "-".PHP_EOL;
}
}
}
$html .= "";
}
}
}
?>
Křížová tabulka
20. 6. 2013 11:29:00
https://webtrh.cz/diskuse/zakomponovani-funkce/#reply914705
Pro odpověď se přihlašte.
Přihlásit