PDA

View Full Version : Unable to Display info


steven21
01-08-2007, 06:46 PM
<?php global $no_of_players;

if ($act==Goals) { $sort=1; $display=$act; } elseif ($act==Assists) { $sort=1; $display=$act; } elseif ($act==Games) { $sort=1; $display="Appearances"; } elseif ($act==PIM) { $sort=1; $display=$act; } elseif ($act==Points) { $sort=1; $display=$act;} elseif ($act==GoalsAgainst) { $sort=1; $display="Goals Conceded"; $g=1;} elseif ($act==Shots) { $sort=1; $display="Shots Against"; $g=1; } elseif ($act==SavePercentage) { $sort=1; $display="Save Percentage"; $sp=1; $g=1;} elseif ($act==ShutOuts) { $sort=1; $display=$act; } else { $sort=""; }



if ($sort !=0) {
if ($g !=0) {
// Goalie
echo ("$display </p>
<table width=\"350\" border=\"0\" align=\"center\">
<tr><td width=\"175\" bgcolor=\"#E7BD1D\"><span class=\"style13\"><strong>Goalie</strong></span></td>
<td width=\"100\" bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style13\"><strong>Team</strong></div></td>
<td width=\"75\"bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style13\"><strong>$act</strong></div></td></tr>");
$count = 1;

if ($sp!=0) {
$query = "SELECT *, IF( Shots = 0, 0, Shots-GoalsAgainst / Shots ) as save_percentage FROM `snl_goalies` ORDER BY $act desc LIMIT $no_of_players";
$result = mysql_query($query) or die ('Unable to show players');
while ( $rows = mysql_fetch_array($result) ) {
$Goalie = $rows['Goalie'];
$Shots = $rows['Shots'];
$GoalsAgainst = $rows['GoalsAgainst'];
$ShutOuts = $rows['ShutOuts'];
$TeamID = $rows['TeamID'];

if ($Shots || $GoalsAgainst == "") {
$Stat1 = $Shots-$GoalsAgainst;
$Stat = $Stat1 / $Shots;
$Stat = number_format($Stat, 2);
} else { $Stat = "0"; }

$query1 = "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
$result1 = mysql_query($query1) or die ('Unable to show players');
$rows1 = mysql_fetch_array($result1);
$TeamName = $rows1['ShortName'];

if($count%2){
echo ("<tr><td bgcolor=\"#FFFFFF\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\">$Stat</div></td></tr>"); $count++; }
else {
echo ("<tr><td bgcolor=\"#EEEEEE\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\">$Stat</div></td> </tr>"); $count++; } }
echo ("</table></p><p class=\"style18\"><a href=\"snlplayers.php\">< Back to top players</a>");

} else {
$query = "SELECT * FROM `snl_goalies` ORDER BY $act desc LIMIT $no_of_players";
$result = mysql_query($query) or die ('Unable to show players');
while ( $rows = mysql_fetch_array($result) ) {
$Goalie = $rows['Goalie'];
$Stat = $rows["$act"];
$TeamID = $rows['TeamID'];

$query1 = "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
$result1 = mysql_query($query1) or die ('Unable to show players');
$rows1 = mysql_fetch_array($result1);
$TeamName = $rows1['ShortName'];

if($count%2){
echo ("<tr><td bgcolor=\"#FFFFFF\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\">$Stat</div></td></tr>"); $count++; }
else {
echo ("<tr><td bgcolor=\"#EEEEEE\"><span class=\"style18\">$Goalie</span></td> <td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\">$Stat</div></td> </tr>"); $count++; } }
echo ("</table></p><p class=\"style18\"><a href=\"snlplayers.php\">< Back to top players</a>");
}
} else {
// regular player
echo ("$act </p>
<table width=\"350\" border=\"0\" align=\"center\">
<tr> <td width=\"175\" bgcolor=\"#E7BD1D\"><span class=\"style18\"><strong>Player</strong></span></td>
<td width=\"100\" bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style18\"><strong>Team</strong></div></td>
<td width=\"75\"bgcolor=\"#E7BD1D\"><div align=\"center\" class=\"style18\"><strong>$act</strong></div></td></tr>");

$count = 1;
$query = "SELECT * FROM `snl_players` ORDER BY $act desc LIMIT $no_of_players";
$result = mysql_query($query) or die ('Unable to show players');
while ( $rows = mysql_fetch_array($result) ) {
$Player = $rows['Player'];
$Stat = $rows["$act"];
$TeamID = $rows['TeamID'];

$query1 = "SELECT * FROM `teams` WHERE `TeamID` = '$TeamID'";
$result1 = mysql_query($query1) or die ('Unable to show players');
$rows1 = mysql_fetch_array($result1);
$TeamName = $rows1['ShortName'];

if($count%2){
echo ("<tr><td bgcolor=\"#FFFFFF\"><span class=\"style18\">$Player</span></td> <td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#FFFFFF\"><div align=\"center\" class=\"style18\">$Stat</div></td></tr>"); $count++; }
else {
echo ("<tr><td bgcolor=\"#EEEEEE\"><span class=\"style18\">$Player</span></td> <td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\"><a href=\"TeamStats.php?TeamID=$TeamID\">$TeamName</a></div></td><td bgcolor=\"#EEEEEE\"><div align=\"center\" class=\"style18\">$Stat</div></td> </tr>"); $count++; } }
echo ("</table></p><p class=\"style18\"><a href=\"snlplayers.php\"> < Back to top players</a>");
}

} else { // show available sorts
include ('snl_players_list.php');
}


?>

I am trying to get the following page http://www.fifeflyers.co.uk/snlplayers.php to display the 'Shut Outs' info but when you click on it, I get the message Unable to show players I was wondering if anyone could see what's wrong with the code?

I cant see it, been looking at it too long now.

Andrew Taylor
01-08-2007, 07:13 PM
Best way to start would be to change all of the "or die" messages

Change them to "Unable to show players1", "Unable to show players2" etc.

That way you'll know which query is failing

If you send me a ticket with the login details, I'll have a look at the database etc. for you

Nick Irvine
02-08-2007, 06:35 PM
Changing the error messages is a good place to start. If you still havent sorted it let me know. I think thats my code?

steven21
02-08-2007, 09:40 PM
Ok, from the 1st "Unable to show player" I have labelled them 1 - 6, and it is the 5th one that gives me the error - unable to show players5.

It is Nick, I have finally got round to trying to add the shut outs to the list. lol

Andrew Taylor
02-08-2007, 09:50 PM
You don't seem to have a field in the database called ShutOuts, so the order by part isn't working

steven21
02-08-2007, 09:56 PM
I have checked and double checked that ShutOuts is in my database, even double checked my spelling, it is definitely there - does the order of the D/B matter?

Andrew Taylor
02-08-2007, 09:59 PM
I can't see a field called ShutOuts in snl_players, only in snl_goalies

steven21
02-08-2007, 10:00 PM
it shouldn't be in the players, it is for the goalies. hmm?

Andrew Taylor
02-08-2007, 10:02 PM
Is this query 5?

$query = "SELECT * FROM `snl_players` ORDER BY $act desc LIMIT $no_of_players";
$result = mysql_query($query) or die ('Unable to show players');

steven21
02-08-2007, 10:07 PM
I am not sure of the order to be honest. just trying to have a look the now

Andrew Taylor
02-08-2007, 10:07 PM
Try replacing the top line with this:

if ($act==Goals) { $sort=1; $display=$act; } elseif ($act==Assists) { $sort=1; $display=$act; } elseif ($act==Games) { $sort=1; $display="Appearances"; } elseif ($act==PIM) { $sort=1; $display=$act; } elseif ($act==Points) { $sort=1; $display=$act;} elseif ($act==GoalsAgainst) { $sort=1; $display="Goals Conceded"; $g=1;} elseif ($act==Shots) { $sort=1; $display="Shots Against"; $g=1; } elseif ($act==SavePercentage) { $sort=1; $display="Save Percentage"; $sp=1; $g=1;} elseif ($act==ShutOuts) { $sort=1; $display=$act; $g=1;} else { $sort=""; }



Which gives this:
http://www.fifeflyers.co.uk/snlplayers.php?act=ShutOuts&g=1

Which seems to work

steven21
02-08-2007, 10:08 PM
Seems ok actually now

Andrew Taylor
02-08-2007, 10:12 PM
It looks like that line has been fixed, probably Nick having a look at the same time

Glad it is working

steven21
02-08-2007, 10:16 PM
so for my other pages, http://www.fifeflyers.co.uk/snlplayers.php if you look at the links on the right, will it be a case of adding the same code to each section of those pages?

Andrew Taylor
02-08-2007, 10:26 PM
Yes, should be just a case of replacing that one line

Edit: Seems to have been done already

steven21
02-08-2007, 10:29 PM
All done. Thanks Andrew!!!!!!

Andrew Taylor
02-08-2007, 10:35 PM
Excellent, glad it is working