The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS and "traffic-lighting" values in a table Re: CSS and “traffic-lighting” values in a table

"mat" wrote:
Hi latte,

See below the php i used for pulling in my data from my matches table:

$r2 = mysql_fetch_array(mysql_query(“SELECT * FROM $teams WHERE team_id='”.$r[“match_team”].”‘”));
echo “n”;
echo “ vs. n”;
echo ““.$r[“match_opponent”].”n”;

if ($match_score1 > $match_score2)
echo ““.$r[“match_score1″].” – “.$r[“match_score2″].”“;
elseif ($match_score1 < $match_score2) { echo "“.$r[“match_score1″].” – “.$r[“match_score2″].”“;
echo ““.$r[“match_score1″].”“.$r[“match_score2″].”“;

$r3 = mysql_fetch_array(mysql_query(“SELECT * FROM $events WHERE event_id='”.$r[“match_event”].”‘”));
echo ““.$r3[“event_name”].”n”;
echo ““.$r[“match_date”].”n”;
echo “


I’ve added a couple of line breaks between the if statements.

You will see that each if, elseif, and else each have a different span: <span class=’loss’>
This is obviously just defined in the stylesheet such as:

.loss { color: #f00}

You can ofcourse credit me in your app if you see fit to :) my website is:

Hi Mat – sorry it’s taken me a long time to reply –
Great – thanks very much for that code! I will indeed credit you if I use it.
Thanks again, bye for now –
– latte