Jump to content

SCOREBOARD css styles for mysql values


mightymouse

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/141749-scoreboard-css-styles-for-mysql-values/
Share on other sites

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.

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.