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] Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.