Jump to content

Changing Images Depending Upon Values In Ranking List


tooNight

Recommended Posts

Hi there in my ladder I want to display a up arrow if playerRankings.pRankingScore is great than playerRankings.pPrevRankingScore or down arrow if less & if the values are the same the display the yellow no change diamond. I would like to display the image in <th>Points +/-</th> column. I have saved the images below to my server and they are in /images under the same filenames. Just wondering if anybody could help me out with this simple if statement?


[img src=\"http://contact14.ics.uci.edu/virus/images/down-arrow-red.gif\" border=\"0\" alt=\"IPB Image\" /]

[img src=\"http://www.westpoint.ltd.uk/example-reports/reports/files/static/arrow-up-green.png\" border=\"0\" alt=\"IPB Image\" /]

[img src=\"http://www.westpoint.ltd.uk/example-reports/reports/files/static/arrow-none.png\" border=\"0\" alt=\"IPB Image\" /]


[code]
<?php
require('library/db_connect.php');    // database connect script.
?>
<?php include 'library/header.inc'; ?>


<?php

    $query  = "SELECT playerRankings.pRankingsID, playerRankings.pRankingScore, playerRankings.pPrevRankingScore, users.username, users.playerName
                         FROM playerRankings, users
               WHERE (playerRankings.pRankingsID = users.username)
               ORDER BY playerRankings.pRankingScore DESC";
              
    $result = mysql_query($query) or die('Error : ' . mysql_error());

    print "<table border=1>\n<tr><th>Rank</th><th>Name</th><th>Score</th><th>Prev Score</th><th>Points +/-</th></tr>\n";
  
        $rank = 1;
    while ($row = mysql_fetch_assoc($result)) {

    print "<tr><td>{$rank}</td><td><a href=\"playerDetails.php?username=$row[username]\">$row[playerName]</a></td><td>{$row['pRankingScore']}</td><td>{$row['pPrevRankingScore']}</td><td></td><tr>\n";

    $rank++;
    }

    
    print "</tr>" .
          "</table>";



    
  
    
    
    

$db_object->disconnect();
?>

<?php include 'library/footer.inc'; ?>
[/code]
Would something like this work?

[code]if($row[pRankingScore] > $row[pPrevRankingScore){
    $img = "arrow-up-green.png";
}
elseif($row[pRankingScore] < $row[pPrevRankingScore){
    $img = "down-arrow-red.gif";
}
else{
    $img = "arrow-none.png";
}[/code]

then wherever you need the image

[code]<img src="images/<?=$img?>">[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.