On my site I have a page that shows players all time stats overall, by season, by games and by team.
The problem i am having is that i have 2 different leagues and i am trying to seperate them by using the leagueid.
when i put it like this i can get it to display the league i want
function overall_points() {
$query = "SELECT playerid, SUM(goals + assists), leagueid FROM player_stats WHERE leagueid = 2 GROUP BY playerid ORDER BY SUM(goals+assists) DESC LIMIT 0, 5";
$result = mysql_query($query) or die(mysql_error());
while($fetch = mysql_fetch_row($result)) {
$string[] = "<tr><td width=200>".$this->convertname($fetch[0])."</td><td>".$fetch[1]."</td></tr>";
}
return $string;
}
but when i put like this
function overall_points() {
$query = "SELECT playerid, SUM(goals + assists), leagueid FROM player_stats WHERE leagueid = '".$league."' GROUP BY playerid ORDER BY SUM(goals+assists) DESC LIMIT 0, 5";
$result = mysql_query($query) or die(mysql_error());
while($fetch = mysql_fetch_row($result)) {
$string[] = "<tr><td width=200>".$this->convertname($fetch[0])."</td><td>".$fetch[1]."</td></tr>";
}
return $string;
}
It shows up blank.
to see what i have you can view at http://theufhl.com/?opt=top5&sid=000000000014&league=2
also here is a bit more code from that page where it starts off. I never made this part of the script that is why i am having problems and i cant get a hold of the guy that did it
<?php
include_once "config.php";
//IF NO LEAGUE VARIABLE IS PASSED, SET THE OPEN SEASON, OR GET FIRST SEASON IF NONE OPEN
[COLOR="Red"] if(!$league) {
$sql_league_statement = "SELECT * FROM league WHERE status = '1'";
$result_league = mysql_query("$sql_league_statement");
$total_league = mysql_numrows($result_league);
$open_league = mysql_result($result_league,0,"id");
$open_league_name = mysql_result($result_league,0,"name");
} else {
$sql_league_statement = "SELECT * FROM league WHERE id = '$league'";
$result_league = mysql_query("$sql_league_statement");
$total_league = mysql_numrows($result_league);
$open_league = mysql_result($result_league,0,"id");
$open_league_name = mysql_result($result_league,0,"name");
}
if(!$league) {
$league = $open_league;
}
class top5 {
function top5() {
//constructor
}[/COLOR]
//------------------------------------------------
//--------- basic functions ----------------------
//------------------------------------------------
[COLOR="Red"] function convertname($id) {
$query = "SELECT fname, lname FROM players WHERE id='$id'";
$result = mysql_query($query) or die(mysql_error());
while(list($fname, $lname)=mysql_fetch_row($result)) {
$fullname = $fname ." ". $lname;
}
return $fullname;
}[/COLOR]
//------------------------------------------------
//--------- here starts the overall stats ----------
//------------------------------------------------
[COLOR="Red"] function overall_points() {
$query = "SELECT playerid, SUM(goals + assists), leagueid FROM player_stats WHERE leagueid = '$league' GROUP BY playerid ORDER BY SUM(goals+assists) DESC LIMIT 0, 5";
$result = mysql_query($query) or die(mysql_error());
while($fetch = mysql_fetch_row($result)) {
$string[] = "<tr><td width=200>".$this->convertname($fetch[0])."</td><td>".$fetch[1]."</td></tr>";
}
return $string;
}[/COLOR]
there is a bunch more code below, but it is like the above only searching for different categories
any help is appriciated...
thanks in advance