Output of the table and its color by condition
I read the value in the file, write it to the variable $read, and in theory, depending on what you read $read using if (...) {...} I output a table and, depending on what I counted in $read, I output the color of the table.
That is, if it is entered "Online" then green, and if "Offline" then red. Please help me do this. Thank you in advance.
1
4 answers
.red {border: 1px; background-color: #ff0000; color: #000000;}
.green {border: 1px; background-color: #00ff00; color: #000000;}
.gray {border: 1px; background-color: #999999; color: #000000;}
And
if ($read == 'Онлайн')
{
echo '<table class="green">';
} else
if ($read == 'Офлайн')
{
echo '<table class="red">';
} else
if ($read == 'На регистрации')
{
echo '<table class="grey">';
};
2
Author: Владимир Клыков, 2011-07-31 15:39:29
In general, it is better to do this kind of thing already through switch ():
So you can take the css from the first option
.red {border: 1px; background-color: #ff0000; color: #000000;}
.green {border: 1px; background-color: #00ff00; color: #000000;}
.gray {border: 1px; background-color: #999999; color: #000000;}
But in php, do this:
switch ($read) {
case 'Онлайн':
echo '<table class="green">';
break;
case 'Оффлайн':
echo '<table class="red">';
break;
case 'На регистрации':
echo '<table class="grey">';
break;
}
1
Author: demenshin, 2011-07-31 16:28:53
.red {border: 1px; background-color: #ff0000; color: #000000;}
.green {border: 1px; background-color: #00ff00; color: #000000;}
.gray {border: 1px; background-color: #999999; color: #000000;}
PHP code:
$tableColor = array('Онлайн' => 'green','Офлайн' => 'red','На регистрации' => 'gray');
echo '<table class="'.$tableColor[$read].'">';
1
Author: GLAGOLA, 2011-07-31 21:02:10
If ($read = = "Online")
{
print <table class='green'>
;
}
else
{
echo <table class='red'>
}
Something like that.
0
Author: Дарика, 2011-07-31 15:01:57