Help

<?php $leaders = mysql_query('SELECT * FROM `playerstats` WHERE `Season_ID` = 12 ORDER BY `playerstats`.`ProPoint` DESC LIMIT 0, 1'); while ($leader = mysql_fetch_assoc($leaders)) { $leadername = $leader[Name]; $leaderphotos = mysql_query('SELECT * FROM `players` WHERE `Name` = $leadername LIMIT 0, 1 '); $leaderphoto = $leaderphotos[Photo]; echo ''.$leaderphoto.''; echo '
'.$leadername.'

'; } echo ''; $players = mysql_query('SELECT * FROM `playerstats` WHERE `Season_ID` = 12 ORDER BY `playerstats`.`ProPoint` DESC LIMIT 1, 9'); while ($player = mysql_fetch_assoc($players)) { echo ''; } echo '
Name G A P
'.$player['Name'].' '.$player['ProG'].' '.$player['ProA'].' '.$player['ProPoint'].'
'; ?>

the chart works fine, but i want the table to print the name and photo of the top scorer above the chart. $leaderphoto should correspond to “Ryan Getzlaf.jpg”, which is the player photo for peyton nydroj, the current leading scorer. however, the value of $leaderphoto is being returned as null.

i’m sure this is very poor code and that there’s a more efficient way to do this ,but if anyone happens to be good at php and sees where i am going wrong, let me know.

you could try something like this:

[php]

<?php $leaders = mysql_query('SELECT * FROM `playerstats` WHERE `Season_ID` = 12 ORDER BY `playerstats`.`ProPoint` DESC LIMIT 0, 1'); while ($leader = mysql_fetch_assoc($leaders)) { $query = mysql_query('SELECT * FROM `players` WHERE `Name` = '.$leader[Name].' ')or die(mysql_error()); $row = mysql_fetch_assoc($query); echo $row[Photo].' '; echo '
'.$leader[Name].'

'; } echo ''; $players = mysql_query('SELECT * FROM `playerstats` WHERE `Season_ID` = 12 ORDER BY `playerstats`.`ProPoint` DESC LIMIT 1, 9'); while ($player = mysql_fetch_assoc($players)) { echo ''; } echo '
Name G A P
'.$player['Name'].' '.$player['ProG'].' '.$player['ProA'].' '.$player['ProPoint'].'
'; ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service