/    Sign up×
Community /Pin to ProfileBookmark

changing colors

Hi all.

This has to be the ulitmate noob question. I have a little php script that I have been trying to modify but not luck.

From the beginning. I have a game server on my linux box and a webserver. On the webserver is a page where I want to display number of players on the server. So in theory it should work like this :

if pleyers > 0 then
print statment in white 1 ( if there is someone on the server )
else
print statment in gray 2 ( if the server is empty )

Here is the code :

[code=php]if ($server->server_num_players > 0 )
{
echo ‘<font color=”#FFFFFF”>’.”Current Map: “.$server->server_map.”<br>”;
echo ‘<font color=”#FFFFFF”>’.”Players: “.$server->server_num_players;
echo ‘<font color=”#FFFFFF”>’.” of “.$server->server_num_players_max;
}
else
{
echo ‘<font color=”#808080”>’.”Current Map: “.$server->server_map.”<br>”;
echo ‘<font color=”#808080″>’.”Players: “.$server->server_num_players;
echo ‘<font color=”#808080″>’.” of “.$server->server_num_players_max;
}[/code]

The number of players are displayed correctly but the font color is always gray no matter if the server is empty or not.

Thanks for your time

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 04.2006 — Worked OK for me. However, I'd recommend getting rid of the deprecated <font> tags, plus compacting things a bit:
[code=php]
$color = ($server->server_num_players > 0) ? "#FFFFFF" : "#808080";
echo "<span style='color: $color;'>Current Map: ".$server->server_map."<br>";
echo "Players: ".$server->server_num_players." of ";
echo $server->server_num_players_max."</span>";
[/code]
Copy linkTweet thisAlerts:
@stebbi67authorAug 07.2006 — Ok, thanks. My code does not work for me, but yours does ?
×

Success!

Help @stebbi67 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...