Jump to content

results being copied over and over no matter whats entered


darkfreaks

Recommended Posts

columns being copied?

 

ok so you got like win loss draw columns for each game for example

Test 1: W:1 L: 1 D:3

 

the problem is it will just copy that information over again. anyone help me out here ???

 

Submitscores.inc.php:

<script type="text/javascript">
function Spiner(num, ref, min, max)
{
        var obj=document.getElementById(ref);
if((parseInt(obj.value)+ num) >= min && (parseInt(obj.value)+ num) <= max)
        {
	obj.value=parseInt(obj.value)+num;
}
}
</script>
<?php
@session_start();
    $nofixtures = "There are no fixtures available to submit results for<br>";
    $notminplayers = "You have not chosen the correct number of players,  min is 5 and max is 10. Go <a href=# onClick='history.go(-1)'>back</a>";
    $maxplayers = 10;
    $minplayers = 5;
    $scorenotmatch = "<div align='center'><img src='images/stage4.png' width='550' height='100' /></div>
<br>Submitted scores do not match,  this has been raised to admins<brs>";
    $scoresubmitted = "<div align='center'><img src='images/stage4.png' width='550' height='100' /></div>
<br>You submission has been matched to the other managers updated <br>";
    $partsubmit = "<div align='center'><img src='images/stage4.png' width='550' height='100' /></div>
<br>Your submission has been accepted,  awaiting other managers submission before data is updated<br>";
    $stageone = "<div align='center'><img src='images/stage1.png' width='550' height='100' /></div><br>
<form method=post action=?page=submitresults>
Select Fixture <br>
_FIXTUREOPTIONS<input type=hidden name=stage value=2>
<input type=submit class='button' value='Next Stage'>
</form>
";
    $stagetwo = "<div align='center'><img src='images/stage2.png' width='550' height='100' /></div>
<br>
<form method=post action=?page=submitresults>
  <b>Final Score</b><br />_HOMETEAMNAME <a onclick=\"Spiner(-1, 'hometeamgoals', 0, 1000);\"><</a>
  <input readonly type='text' maxlength=2 size=2 name=hometeamgoals id='hometeamgoals' value='0' width=3 / class='button' style='text-align:center'>
  <a onclick=\"Spiner(1, 'hometeamgoals', 0, 1000);\">></a>    <b>Vs.</b>    <a onclick=\"Spiner(-1, 'awayteamgoals', 0, 1000);\"><</a>
  <input readonly type='text' maxlength=2 size=2 name=awayteamgoals id='awayteamgoals' value='0' width=3 class='button' style='text-align:center'/>
  <a onclick=\"Spiner(1, 'awayteamgoals', 0, 1000);\">>  </a>_AWAYTEAMNAME<br>
  <br>
  <b>Select players from _YOURTEAMNAME who Played?</b><br>
  _YOURTEAMCHECKS<br>
  <input type=hidden name=stage value=3>
  <input type=hidden name=awayteamid value=_AWAYTEAMID>
  <input type=hidden name=hometeamid value=_HOMETEAMID>
  <input type=hidden name=fixture value=_FIXTURE>
  <input type=submit class='button' value='Next Stage'>
</form>
";
    $stagethree =  "<div align='center'><img src='images/stage3.png' width='550' height='100' /></div>
<br>
<form method=post action=?page=submitresults>
_YOURTEAMNAME
<br><br>
<table width='750'>
<tr><td width='154'><b>Player</b></td><td width='95' style='text-align:center'><b>Goals</b></td><td width='95' style='text-align:center'><b>Assists</b></td><td width='95' style='text-align:center'><b>Yellow Cards</b></td><td width='95' style='text-align:center'><b>Red Cards</b></td><td width='95' style='text-align:center'><b>Rating</b></td><td width='53' style='text-align:center'><b>Motm</b></td></tr>
_YOURPLAYERTABLE
</table>
<input type=submit value='Submit Fixture' class='button'>
<input type=hidden name=stage value=4>
<input type=hidden name=awayteamid value=_AWAYTEAMID>
<input type=hidden name=hometeamid value=_HOMETEAMID>
<input type=hidden name=awayteamgoals value=_AWAYTEAMGOALS>
<input type=hidden name=hometeamgoals value=_HOMETEAMGOALS>
<input type=hidden name=fixture value=_FIXTURE>
</form>
<tr>
  <td> </td>
  <td>
";
    $playerrow = "<tr><td>_PLAYERNAME</td>
<td style='text-align:center'><a onclick=\"Spiner(-1, '_GOALID', 0, 1000);\"><</a>
<input readonly type='text' style='text-align:center' class='button' maxlength=2 size=2 name=goals[] id='_GOALID' value='0' width=3 />
<a onclick=\"Spiner(1, '_GOALID', 0, 10000);\">></a>
</td>
<td style='text-align:center'><a onclick=\"Spiner(-1, '_ASSISTID', 0, 1000);\"><</a>
<input readonly type='text' style='text-align:center' class='button' maxlength=2 size=2 name=assits[] id='_ASSISTID' value='0' width=3 />
<a onclick=\"Spiner(1, '_ASSISTID', 0, 1000);\">></a>
</td>
<td style='text-align:center'><a onclick=\"Spiner(-1, '_YCARDID', 0, 1000);\"><</a>
<input readonly type='text' style='text-align:center' class='button' maxlength=2 size=2 name=ycards[] id='_YCARDID' value='0' width=3 />
<a onclick=\"Spiner(1, '_YCARDID', 0, 1000);\">></a>
</td>
<td style='text-align:center'><a onclick=\"Spiner(-1, '_RCARDID', 0, 1000);\"><</a>
<input readonly type='text' style='text-align:center' class='button' maxlength=2 size=2 name=rcards[] id='_RCARDID' value='0' width=3 />
<a onclick=\"Spiner(1, '_RCARDID', 0, 1000);\">></a>
</td>
<td style='text-align:center'><a onclick=\"Spiner(-1, '_RATINGID', 0, 10);\"><</a>
<input readonly type='text' style='text-align:center' class='button' maxlength=2 size=2 name=rating[] id='_RATINGID' value='0' width=3 />
<a onclick=\"Spiner(1, '_RATINGID', 0, 10);\">></a>
</td>
<td style='text-align:center'><input type=checkbox name=motm[] value=1>
<input type=hidden value=_PLAYERID name=players[]></td></tr>";
    $stagefour = "Submission should be completed,  Show done screen";
    $stage = $_POST[stage];
    
    if($stage == "")$stage = 1;
    switch($stage)
    {
        case 1 :
            
                {
                $tempcode = fixtureoptions();
                
                if($tempcode == "none")
                {
                    $htmlcode = $nofixtures;
                }
                else
                {
                    $htmlcode = str_replace("_FIXTUREOPTIONS", $tempcode, $stageone);
                }

                echo $htmlcode;
                break;
        }

        case 2 :
            
                {
                $query = "SELECT * FROM fixtures WHERE id = " . $_POST[fixture];
                $result = $GLOBALS[db]->query($query);
                $row = $result->fetch_assoc();
                $htmlcode = str_replace("_YOURTEAMNAME", getteam($_SESSION[team]), $stagetwo);
                $htmlcode = str_replace("_HOMETEAMNAME", getteam($row[hometeam]), $htmlcode);
                $htmlcode = str_replace("_AWAYTEAMNAME", getteam($row[awayteam]), $htmlcode);
                $htmlcode = str_replace("_HOMETEAMID", $row[hometeam], $htmlcode);
                $htmlcode = str_replace("_AWAYTEAMID", $row[awayteam], $htmlcode);
                $htmlcode = str_replace("_FIXTURE", $_POST[fixture], $htmlcode);
                $htmlcode = str_replace("_YOURTEAMCHECKS", getplayers($_SESSION[team]), $htmlcode);
                echo $htmlcode;
                break;
        }

        case 3 :
            
                {
                
                if(sizeof($_POST[players]) < $minplayers || sizeof($_POST[players]) > $maxplayers)
                {
                    $htmlcode = $notminplayers;
                }
                else
                {
                    $htmlcode = str_replace("_YOURTEAMNAME", getteam($_SESSION[team]), $stagethree);
                    $htmlcode = str_replace("_YOURPLAYERTABLE", printplayers(), $htmlcode);
                    $htmlcode = str_replace("_HOMETEAMID", $_POST[hometeamid], $htmlcode);
                    $htmlcode = str_replace("_AWAYTEAMID", $_POST[awayteamid], $htmlcode);
                    $htmlcode = str_replace("_HOMETEAMGOALS", $_POST[hometeamgoals], $htmlcode);
                    $htmlcode = str_replace("_AWAYTEAMGOALS", $_POST[awayteamgoals], $htmlcode);
                    $htmlcode = str_replace("_FIXTURE", $_POST[fixture], $htmlcode);
                }

                echo $htmlcode;
                break;
        }

        case 4 :
            
                {
                $query = "Select * from fixtures where id = " . $_POST[fixture];
                $result = $db->query($query);
                $row = $result->fetch_assoc();
                $homegoals = $_POST[hometeamgoals];
                $awaygoals = $_POST[awayteamgoals];
                $fixstatus = 4;
                $league = $row[league];
                
                if($row[status] == 1)
                {
                    // update the fixture set scores and status to 2 and which team submitted, motm
				// insert player match rows for each submitted player,  player, fixture, goals, assists, redcards, yellow cards, motm, rating, status as 0
                    $motm = 0;
                    for($x = 0; $x < sizeof($_POST[players]); $x++)
                    {
                        //$query =  getuser($_POST[players][$x]) . " " . $_POST[goals][$x] . " " . $_POST[assits][$x] . " " . $_POST[ycards][$x] . " " . $_POST[rcards][$x] . " " . $_POST[rating][$x] . "<br>";
                        $query = "INSERT INTO `playermatchdata` (`id` ,`player` , `fixture` ,`goals` ,`assits` ,`redcards` ,`yellowcards` ,`motm` ,`rating` ,`status`, `team`) VALUES (
										NULL ," .  $_POST[players][$x] . ", " . $_POST[fixture] . ", ". $_POST[goals][$x] . ", " . $_POST[assits][$x] . ", " . $_POST[rcards][$x] . ", " . $_POST[ycards][$x] . ", '$_POST[motm][$x]', ". $_POST[rating][$x] . ", '0', $_SESSION[team])";
                        $db->query($query);
                        
                        if($_POST[motm][$x] == "1")
                        {
                            $motm = $_POST[players][$x];
                        }

                    }

                    $query = "update fixtures set hometeamgoals = " . $_POST[hometeamgoals] . ", awayteamgoals = ". $_POST[awayteamgoals] . ", subby = " . $_SESSION[team] . ", status = 2, motm=" . $motm . " where id =" . $_POST[fixture];
                    $db->query($query);
                    echo $partsubmit;
                }
                else
                {
                    // insert player match rows for each submitted player,  player, fixture, goals, assists, redcards, yellow cards, motm, rating, status as 0
                    
                    if($row[hometeamgoals] != $_POST[hometeamgoals])$fixstatus = 3;
                    
                    if($row[awayteamgoals] != $_POST[awayteamgoals])$fixstatus = 3;
                    $motm = 0;
                    for($x = 0; $x < sizeof($_POST[players]); $x++)
                    {
                        //$query =  getuser($_POST[players][$x]) . " " . $_POST[goals][$x] . " " . $_POST[assits][$x] . " " . $_POST[ycards][$x] . " " . $_POST[rcards][$x] . " " . $_POST[rating][$x] . "<br>";
                        $query = "INSERT INTO `playermatchdata` (`id` ,`player` , `fixture` ,`goals` ,`assits` ,`redcards` ,`yellowcards` ,`motm` ,`rating` ,`status`, `team`) VALUES (
										NULL ," .  $_POST[players][$x] . ", " . $_POST[fixture] . ", ". $_POST[goals][$x] . ", " . $_POST[assits][$x] . ", " . $_POST[rcards][$x] . ", " . $_POST[ycards][$x] . ", ' " . $_POST[motm][$x] . "', ". $_POST[rating][$x] . ", '0', $_SESSION[team])";
                        $db->query($query);
                        
                        if($_POST[motm][$x] == "1")
                        {
                            $motm = $_POST[players][$x];
                        }

                    }

                    
                    if($fixstatus == 4)
                    {
                        
                        if($motm == 0)$query = "update fixtures set status = 4 where id = " . $_POST[fixture];
                        else$query = "update fixtures set status = 4, motm = $motm where id = " . $_POST[fixture];
                        $db->query($query);
                        // verify score of fixture,  if its fine set fixture status to 4 else 3
                        $query = "update playermatchdata set status = 1 where fixture = " . $_POST[fixture];
                        $db->query($query);
                        //do bulk updates on players setting status to 1 if same fixture id and fixture status = 4
					//do pldata updates with all the player info where fixture id is same and fixture status = 4
                        $query = "select * from playermatchdata where fixture = " . $_POST[fixture];
                        $result = $db->query($query);
                        for($x = 0; $x < $result->num_rows; $x++)
                        {
                            $row = $result->fetch_assoc();
                            $userquery = "select * from pldata where player = " . $row[player] . " and league = " . $league;
                            $userresult = $db->query($userquery);
                            
                            if($userresult->num_rows < 1)
                            {
                                $insertquery = "INSERT INTO `pldata` (`id` ,`player` ,`goals` ,`assists` ,`redcards` ,`yellowcards` ,`rating` ,`league`, `motm`) VALUES (NULL , '$row[player]', '$row[goals]', '$row[assits]', '$row[redcards]', '$row[yellowcards]', '$row[rating]', '$league', '$row[motm]')";
                                $db->query($insertquery);
                            }
                            else
                            {
                                $userrow = $userresult->fetch_assoc();
                                //	player 	fixture 	goals 	assits 	redcards 	yellowcards 	motm 	rating 	status
                                $rating = $row[rating] + $userrow[rating];
                                $goals =  $row[goals] + $userrow[goals];
                                $assits = $row[assits] + $userrow[assits];
                                $redcards = $row[redcards] + $userrow[redcards];
                                $yellowcards = $row[yellowcards] + $userrow[yellowcards];
                                $motm = $row[motm] + $userrow[motm];
                                $updatequery = "update pldata set goals = " . $goals. ", assists = " . $assits . ", redcards = " . $redcards . ", yellowcards = " . $yellowcards . ", rating = " . $rating . " where player = " . $row[player] . " and league = " . $league;
                                $db->query($updatequery);
                            }

                        }

                        
                        if($homegoals == $awaygoals)
                        {
                            $homewon = 0;
                            $homelost = 0;
                            $homedraw = 1;
                            $homepoints = 1;
                            $awaywon = 0;
                            $awaylost = 0;
                            $awaydraw = 1;
                            $awaypoints = 1;
                            $homegd = 0;
                            $awaygd = 0;
                            // Draw
                        }
                        else
                        if($homegoals > $awaygoals)
                        {
                            // Home is winner
                            $homewon = 1;
                            $homelost = 0;
                            $homedraw = 0;
                            $homepoints = 3;
                            $awaywon = 0;
                            $awaylost = 1;
                            $awaydraw = 0;
                            $awaypoints = 0;
                            $homegd = $homegoals - $awaygoals;
                            $awaygd = $awaygoals - $homegoals;
                        }
                        else
                        {
                            // Away is winner
                            $homewon = 0;
                            $homelost = 1;
                            $homedraw = 0;
                            $homepoints = 0;
                            $awaywon = 1;
                            $awaylost = 0;
                            $awaydraw = 0;
                            $awaypoints = 3;
                            $homegd = $homegoals - $awaygoals;
                            $awaygd = $awaygoals - $homegoals;
                        }

                        $query = "select * from tldata where tid = $_POST[awayteamid] and lid = $league";
                        //echo "<br>" . $query . "<br>";
                        $result = $db->query($query);
                        $row = $result->fetch_assoc();
                        $tempwon = $row[won] + $homewon;
                        $templost = $row[lost] + $homelost;
                        $tempdraws = $row[draws] + $homedraw;
                        $tempgd = $row[gd] + $homegd;
                        $tempplayed = $row[played] + 1;
                        $temppoints = $row[points] + $homepoints;
                        /*
			echo "Won : $tempwon = $row[won] +  $homewon<br>";
			echo "Lost : $templost = $row[lost] + $homelost<br>";
			echo "Draw : $tempdraws = $row[draws] + $homedraw<br>";
			echo "GD: $tempgd = $row[gd] + $homegd<br>";
			echo "Played : $tempplayed = $row[played] + 1<br>";
			echo "Points : $temppoints = $row[points] + $homepoints<br>";
			*/
                        $updatequery = "update tldata set won = $tempwon, lost = $templost, draws = $tempdraws, gd = $tempgd, played = $tempplayed, points = $temppoints where  tid = $_POST[hometeamid] and lid = $league";
                        $db->query($updatequery);
                        //echo "<br>" . $updatequery . "<br>";
                        $query = "select * from tldata where tid = $_POST[awayteamid] and  tid = $_POST[awayteamid] and lid = $league";
                        $result = $db->query($query);
                        $row = $result->fetch_assoc();
                        //echo "<br>" . $query . "<br>";
                        $tempwon = $row[won] + $awaywon;
                        $templost = $row[lost] + $awaylost;
                        $tempdraws = $row[draws] + $awaydraw;
                        $tempgd = $row[gd] + $awaygd;
                        $tempplayed = $row[played] + 1;
                        $temppoints = $row[points] + $awaypoints;
                        /*
			echo "Won : $tempwon = $row[won] + $awaywon<br>";
			echo "Lost : $templost = $row[lost] + $awaylost<br>";
			echo "Draw : $tempdraws = $row[draws] + $awaydraw<br>";
			echo "GD: $tempgd = $row[gd] + $awaygd<br>";
			echo "Played : $tempplayed = $row[played] + 1 <br>";
			echo "Points :$temppoints = $row[points] + $awaypoints<br>";
			*/
                        $updatequery = "update tldata set won = $tempwon, lost = $templost, draws = $tempdraws, gd = $tempgd, played = $tempplayed, points = $temppoints where  tid = $_POST[awayteamid] and lid = $league";
                        $db->query($updatequery);
                        //echo "<br>" . $updatequery . "<br>";
                        echo $scoresubmitted;
                    }
                    else
                    {
                        $query = "update fixtures set status = 3 where id = " . $_POST[fixture];
                        $db->query($query);
                        // verify score of fixture,  if its fine set fixture status to 4 else 3
                        echo $scorenotmatch;
                    }

                }

                $htmlcode = $stagefour;
                //echo "Fixture is " . $_POST[fixture] . "<br>";
			//echo $_POST[hometeamgoals] . " " . getteam($_POST[hometeamid]) . " vs " . getteam($_POST[awayteamid]) . " " . $_POST[awayteamgoals] . "<br>";
			//echo $htmlcode;
			//$playerrow = "<tr><td>_PLAYERNAME</td><td><input name=goals[] type=text></td><td><input name=assits[] type=text></td><td><input name=ycards[] type=text></td><td><input name=rcards[] type=text></td><td><input name=rating[] type=text><input type=hidden value=_PLAYERID name=players[]></td></tr>";
                break;
        }

}



// -- Function Name : fixtureoptions
// -- Params : 
// -- Purpose : 
function fixtureoptions()
{
    $query = "SELECT * FROM fixtures WHERE week <= " . $_SESSION[currentweek] . " and ((awayteam = " . $_SESSION[team] . " and not subby = " . $_SESSION[team] . ") or (hometeam = " . $_SESSION[team] . " and not subby = " . $_SESSION[team] . ")) and not status > 2 and not status = 0 order by id";
    //SELECT * FROM fixtures WHERE week <= 1 and ((awayteam = 1 and not subby = 1) or (hometeam = 1 and not subby = 1)) and not status >= 2 order by id
    $result = $GLOBALS[db]->query($query);
    
    if($result->num_rows < 1)
    {
        $htmlcode = "none";
    }
    else
    {
        $htmlcode = "<select name=fixture>";
        for($x = 0; $x < $result->num_rows; $x++)
        {
            $row = $result->fetch_assoc();
            $htmlcode .=  "<option value=". $row[id] . ">" . getteam($row[hometeam]) . " vs " . getteam($row[awayteam]) . "</option>";
        }

        $htmlcode .= "</select>";
    }

    return $htmlcode;
}



// -- Function Name : getplayers
// -- Params : $id
// -- Purpose : 
function getplayers($id)
{
    $query = "SELECT * FROM users WHERE team = " . $id . " order by gamertag";
    $result = $GLOBALS[db]->query($query);
    $htmlcode = "";
    for($x = 0; $x < $result->num_rows; $x++)
    {
        $row = $result->fetch_assoc();
        $htmlcode .=  "<input type=checkbox name=players[] value=" . $row[id] . "> " . $row[gamertag] . "<br>";
    }

    return $htmlcode;
}



// -- Function Name : printplayers
// -- Params : 
// -- Purpose : 
function printplayers()
{
    $htmlcode = "";
    //echo sizeof($_POST[players]) . "player 0 " . $_POST[players][0] . "<br>";
    for($x = 0; $x < sizeof($_POST[players]); $x++)
    {
        //echo "<br>" . $x . "<br>";
        $htmlcode .= str_replace("_PLAYERNAME", getuser($_POST[players][$x]), $GLOBALS[playerrow]). "\n";
        $htmlcode = str_replace("_PLAYERID", $_POST[players][$x], $htmlcode);
        $htmlcode = str_replace("_GOALID", "GOAL" . $_POST[players][$x] , $htmlcode);
        $htmlcode = str_replace("_RATINGID", "RATING" . $_POST[players][$x] , $htmlcode);
        $htmlcode = str_replace("_YCARDID", "YCARD" . $_POST[players][$x] , $htmlcode);
        $htmlcode = str_replace("_RCARDID", "RCARD" . $_POST[players][$x] , $htmlcode);
        $htmlcode = str_replace("_ASSISTID", "ASSIST" . $_POST[players][$x] , $htmlcode);
    }

    return $htmlcode;
}

/*
Players Who Played = Min 5 players when stats submitted to automatically update personal stats<br>
Goal Scorers =  Automatically go onto a site top 10 and league top 10 goal scorer charts<br>
Assisters = Automatically go onto a site top 10 and a league top 10 assists charts<br>
Man Of The Match =  Automatically go onto a site top 10 and a league top 10 Motm charts<br>
Rating Points = More to be explained later<br>
*/
?>

 

 

 

 

Are you meant to be creating a new row in the database? Can you clarify the problem a little more?

 

Currently you have 4 queries concerning the table `tldata`;

 

$query = "select * from tldata where tid = $_POST[awayteamid] and lid = $league";
$updatequery = "update tldata set won = $tempwon, lost = $templost, draws = $tempdraws, gd = $tempgd, played = $tempplayed, points = $temppoints where  tid = $_POST[hometeamid] and lid = $league";
$query = "select * from tldata where tid = $_POST[awayteamid] and  tid = $_POST[awayteamid] and lid = $league";
$updatequery = "update tldata set won = $tempwon, lost = $templost, draws = $tempdraws, gd = $tempgd, played = $tempplayed, points = $temppoints where  tid = $_POST[awayteamid] and lid = $league";

 

you only SELECT or UPDATE

ok so i finally figured out the gist of the problem team 1 info is being submitted as team 2 info so no  outcome can be decided  :-\

 

since the code is dragged out and complicated could someone find the general areea of the problem so i can fix it? :-X

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.