php color change - Online - Offline
php color change - Online - Offline
Hi.
I need help figuring out how to make the php script change colors on a status. ie Online - green, Offline - red.
I am not php programmer, but to illustrate the idea it should look smth like this:
if any body knows the script please reply. Thanks
P.S. Script should be suitable for multiple servers
I need help figuring out how to make the php script change colors on a status. ie Online - green, Offline - red.
I am not php programmer, but to illustrate the idea it should look smth like this:
Code: Select all
<?
$server[n][\'status\'] = \"Online\"
print(\"$server[n][\'status\']\");
if($server[n][\'status\']] == \"Online\")
{
$color = \"#00FF00\";
}
else
{
$color = \"#FF0000\";
}
print(\"<font color=\\\"$color\\\">\\n\");
?>
P.S. Script should be suitable for multiple servers
i did not even think that this one should work
Warning: Unexpected character in input: \'\\\' (ASCII=92) state=1 in /var/www/html/stat2/index0.php on line 304
Parse error: parse error, unexpected $ in /var/www/html/stat2/index0.php on line 326
on line: 304 $server[n] etc..
on line: 326 end of the html file
Warning: Unexpected character in input: \'\\\' (ASCII=92) state=1 in /var/www/html/stat2/index0.php on line 304
Parse error: parse error, unexpected $ in /var/www/html/stat2/index0.php on line 326
on line: 304 $server[n] etc..
on line: 326 end of the html file
Jay.
I really dont know that much about php. So I was just hoping for an existing script. The one I put together was taken from here http://www.php-scripts.com/php_diary/example5.phps and I just modified to what I think it should look like, for my purposes. But I'm not really sure what I am doing...
I really dont know that much about php. So I was just hoping for an existing script. The one I put together was taken from here http://www.php-scripts.com/php_diary/example5.phps and I just modified to what I think it should look like, for my purposes. But I'm not really sure what I am doing...
Hi Jay. Ok this one seems to work.
$server[x] - when I change \"x\" to any of the server numbers (0-4) they all change color (red or green depending on which stream is online). So now I need to figure out how to make each stream change colors accordingly. Please suggest. Thank you.
Here is the script:
$server[x] - when I change \"x\" to any of the server numbers (0-4) they all change color (red or green depending on which stream is online). So now I need to figure out how to make each stream change colors accordingly. Please suggest. Thank you.
Here is the script:
Code: Select all
<?php include(\"includes.php\");?>
<?
$status = $server[x][\'status\'];
if($status == \"Online\")
{
$color = \"#009900\";
}
else
{
$color = \"#FF0000\";
}
print(\"<font color=\\\"$color\\\">\\n\")
?>
<p>Stream 0
<?php echo $server[0][\'bitrate\']; ?><?php echo $server[0][\'status\'];?><?php echo $server[0][\'listeners\']; ?>
<p>Stream 1
<?php echo $server[1][\'bitrate\']; ?><?php echo $server[1][\'status\'];?><?php echo $server[1][\'listeners\']; ?>
<p>Stream 2
<?php echo $server[2][\'bitrate\']; ?><?php echo $server[2][\'status\'];?><?php echo $server[2][\'listeners\']; ?>
<p>Stream 3
<?php echo $server[3][\'bitrate\']; ?><?php echo $server[3][\'status\'];?><?php echo $server[3][\'listeners\']; ?>
<p>Stream 4
<?php echo $server[4][\'bitrate\']; ?><?php echo $server[4][\'status\'];?><?php echo $server[4][\'listeners\']; ?>
- Jay
- Will work for food (Administrator)
- Posts: 3022
- Joined: Mon Jan 14, 2002 12:48 am
- Location: Next Door
- Contact:
you just do that same if statement for all your servers. You should probably do a While (list() = each()) type deal so that it rotates through all your servers. Check out php.net for information on loops. If that is not something you want to pursue then just do a if statement for each server manually.
- Jay
Ooofff. Ok Done - Took me several hours. Thanks for the tips Jay.
Here it is, if anybody needs it
Here it is, if anybody needs it
Code: Select all
// Replace \\\"x\\\" with server numbers
<?php echo $server[x][\\\'bitrate\\\']; ?>
<?$status =$server[x][\\\'status\\\'];if($status == \\\"Online\\\"){$color = \\\"#009900\\\";}else{$color = \\\"#FF0000\\\";}print(\\\"<font color=\\\\\\\"$color\\\\\\\"> $status </font>\\\")?>
<?php echo $server[x][\\\'listeners\\\'];?>