Location: PHPKode > projects > Gatito Prediction League > gatito_pred_league/admin/running_tot.php
<?
include "../templates/connect_db.php";
$query=mysql_query("SELECT * FROM users WHERE username ='admin'");
while ($row =@ mysql_fetch_array($query)) {@$week=$row[week];
$new_week=$week+1;}; 

$query=mysql_query("SELECT * FROM checker WHERE week ='$week' ");
while ($row =@ mysql_fetch_array($query)) { 
	@$game=$row[game]; @$h_score=$row[h_score];@$h_team=$row[home_team];@$a_team=$row[away_team]; @$a_score=$row[a_score];@$result=$row[result];

echo "<br><B>game $game: $h_team $h_score v $a_score $a_team</B><br>";
$uquery=mysql_query("SELECT * FROM results WHERE week ='$week' and game = '$game'   order by username");
while ($urow =@ mysql_fetch_array($uquery)) {

@$uh_score=$urow[h_score]; 
@$ua_score=$urow[a_score];
@$uresult=$urow[result]; 
@$user=$urow[username];
if ($user != "admin") {
	
	$pts=0;
	$sco=0;
	$res=0;
	if ($uresult == $result) {$res=1;}
if ($h_score == $uh_score AND $a_score == $ua_score) {$sco=2;};
$pts=$res+$sco;
echo "$user: prediction $uh_score v $ua_score -----points $pts<br>";

	mysql_query("UPDATE results SET pts = '$pts' WHERE username = '$user' AND week = '$week' AND game='$game' AND $result !='9'")or die (mysql_error()); 
	};

};
};
$tquery=mysql_query("SELECT * FROM users");
while ($trow =@ mysql_fetch_array($tquery)) {@$user=$trow[username];
$pts=0;
$query=mysql_query("SELECT pts FROM results WHERE username='$user'");
while ($row =@ mysql_fetch_array($query)) {@$tot=$tot+$pts;
echo $pts;};
echo "$user: $pts points <br>";
$tquery=mysql_query("SELECT * FROM users");
while ($trow =@ mysql_fetch_array($tquery)) {@$user=$trow[username];
$pts=0;
$tot=0;
$query=mysql_query("SELECT pts FROM results WHERE username='$user'");
while ($row =@ mysql_fetch_array($query)) {
@$pts=$row[pts];
	@$tot=$tot+$pts;
};
echo "<br> $user: $tot points <br>";
mysql_query("UPDATE users SET score = '$tot' WHERE username='$user'");

};
};


	?>
Return current item: Gatito Prediction League