tooNight Posted April 28, 2006 Share Posted April 28, 2006 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]<?phprequire('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] Link to comment https://forums.phpfreaks.com/topic/8613-changing-images-depending-upon-values-in-ranking-list/ Share on other sites More sharing options...
sanfly Posted April 28, 2006 Share Posted April 28, 2006 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] Link to comment https://forums.phpfreaks.com/topic/8613-changing-images-depending-upon-values-in-ranking-list/#findComment-31602 Share on other sites More sharing options...
tooNight Posted April 28, 2006 Author Share Posted April 28, 2006 Yes works a treat, thanks matey.Had to close the ] on the pRankingScore of the IF statement but apart from that it was fine.Thanks alot Link to comment https://forums.phpfreaks.com/topic/8613-changing-images-depending-upon-values-in-ranking-list/#findComment-31607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.