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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.