i am having some problems with my echo '<tr style="background-color: . $color . '">';
it keeps giving me Parse error: syntax error, unexpected 'background' (T_STRING) in C:\xampp\htdocs\test.php line 146
and i am pretty new to php so i have no clue what i can do.
My purpes with this code is to get some information from a colum in mysql database and then show it as a table in a website(that i have allready fixed, but i need the colors to work) and then it is going to color some of the table rows after some of their value in the database.
P.S: This is not my whole code.
hope someone can help, Thanks.
while($row = mysql_fetch_array($rs)) {
if ( ($row['Flyttet'] == "NEI") && ($row['Slettet'] != "JA") && ($row['Delt'] != "NEI") ) {
$red ='#ff0000';
}
else {
$red = false;
}
if ( (($row['Flyttet'] == "NEI") && ($row['Slettet'] != "NEI") && ($row['Delt'] != "JA")) || (($row['Flyttet'] == "JA") && ($row['Slettet'] != "NEI") && ($row['Delt'] != "JA")) ) {
$gul ='#FFFF00';
}
else {
$gul = false;
}
if ( ($row['Flyttet'] == "JA") && ($row['Slettet'] != "NEI") && ($row['Delt'] != "NEI") ) {
$blue ='#1E90FF';
}
else {
$blue = false;
}
if ( ($row['Flyttet'] == "NEI") && ($row['Slettet'] != "NEI") && ($row['Delt'] != "JA") ) {
$green ='#3CB371';
}
else {
$green = false;
}
$color = ";
if(!$red && !$gul && !$blue) $color = $green;
if(!$red && !$gul && !$green) $color = $blue;
if(!$red && !$green && !$blue) $color = $gul;
if(!$green && !$gul && !$blue) $color = $red;
//Første kolone som skal vises
echo '<tr style="background-color: . $color . '">';
echo "<td>" . utf8_encode($row['ID']) . "</td>";
echo "<td>" . utf8_encode($row['Vsite']) . "</td>";
echo "<td>" . utf8_encode($row['Registrar']) . "</td>";
echo "<td>" . utf8_encode($row['Eier']) . "</td>";
echo "<td>" . utf8_encode($row['NS']) . "</td>";
echo "<td>" . utf8_encode($row['A']) . "</td>";
echo "<td>" . utf8_encode($row['MX']) . "</td>";
echo "<td>" . utf8_encode($row['Flyttet']) . "</td>";
echo "<td>" . utf8_encode($row['Slettet']) . "</td>";
echo "<td>" . utf8_encode($row['Delt']) . "</td>";
echo "<td>" . utf8_encode($row['Behkd']) . "</td>";
echo "<td>" . utf8_encode($row['Varenr']) . "</td>";
echo "<td>" . utf8_encode($row['Server']) . "</td>";
echo "<td>" . utf8_encode($row['Sistoppdatert']) . "</td>";
echo "</tr>";
}