$leaderphoto null

images php coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Mon Aug 15, 2011 2:16 pm

$leaderphoto null

Postby shyft » Mon Aug 15, 2011 2:18 pm

$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 '<img src=http://www.vhlsim.net/image/players/'.$leaderphoto.'><br><font size=4><b>'.$leadername.'</b></font><br><br>';
echo '<table border="1" align=center cellpadding="2" cellspacing="3" width="180">
$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 '<tr><td>'.$player['Name'].'</td><td>'.$player['ProG'].'</td><td>'.$player['ProA'].'</td><td>'.$player['ProPoint'].'</td></tr>';
echo '</table>';

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.

php-forum Fan User
php-forum Fan User
Posts: 577
Joined: Fri Aug 05, 2011 9:53 am

Re: $leaderphoto null

Postby NigelRen » Mon Aug 15, 2011 11:56 pm

With the first mysql_query - your doing a mysql_fetch_assoc to fetch the values from the query, but the one where your retrieving the $leaderphotos, your not. Could this be why your not getting the values back from the query?

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 2 guests