mightymouse Posted January 21, 2009 Share Posted January 21, 2009 Hi Im in the process of creating a scoreboard for kids at my school. basically there will be 4 fields for them to fill out and send the data to the mysql table. the results will be displayed by the descending order of the score. basically I want the css cell of the table to change when they reach a certain score so they receive gold silver and bronze colours when they reach a certain score. Im sure this is possible ?? does anyone know of a tutorial or a term I could search to get some info on this kind of subject. Quote Link to comment Share on other sites More sharing options...
lostprophetpunk Posted January 21, 2009 Share Posted January 21, 2009 You would have to call the data from the MySQL table and then have an if statement for it like the one below. Have this above your table...(if you know how to fetch the data then ignore the first part) $sql = "SELECT * FROM `table`"; $res = mysql_query($sql) or die(mysql_error()); $Data = mysql_fetch_array($res); $score = $Data['scorefield']; //scorefield being name of score in db $scorecolour = "ffffff"; // I have used 20 as an example, change it to what you want // I have also used '>' for more than but you can use '>=' for more than or equal to if($score > 20) { $scorecolour = "cccccc"; //you can set this value to the hex value of the colour you want } Then in your <td> code have this... <td style='background-color: <?php echo $scorecolour ?>;'>$score</td> I hope this has helped you. 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.