Hello all,
I am trying to dynamically generate bgcolors with to help populate some information for a site. Here is the code snipets
function addColor($data){
$this->color1 = "#ff0000";
$this->color2 = "#00ff00";
$this->color3 = "#0000ff";
$this->color4 = "#ffff00";
$this->color5 = "#ff00ff";
$this->color6 = "#f3e3d3";
$this->color7 = "#11ee33";
$this->color8 = "#ab55e1";
$this->color9 = "#12c522";
$this->color10 = "#f033a9";
$this->color11 = "#44e2f1";
$this->color12 = "#3af422";
for ($a = 1; $a <= 12; $a++){
//V4 Pre-Trip Colors
if ($data["zonename$j"] == "BRAKES"){
$background[$a' = sprintf("bgcolor=\"%s\"", $this->color1);
}else if ($data["zonename$j"] == "RIGHT FRONT"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color2);
}else if ($data["zonename$j"] == "REAR LIGHTING"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color3);
}else if ($data["zonename$j"] == "LEFT REAR"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color4);
}else if ($data["zonename$j"] == "INSIDE BUS"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color5);
}else if ($data["zonename$j"] == "FRONT LIGHTING"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color6);
}else if ($data["zonename$j"] == "ENTERING BUS"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color7);
}else if ($data["zonename$j"] == "ENGINE COMPARTMENT"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color8);
}else if ($data["zonename$j"] == "DRIVERS SEAT AREA"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color9);
}else if ($data["zonename$j"] == "RIGHT REAR"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color10);
}else if ($data["zonename$j"] == "LEFT FRONT"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color11);
}
// Truck Pre-Trip colors
else if ($data["zonename$j"] == "TRAILER FRONT"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color1);
}else if ($data["zonename$j"] == "TRAILER LEFT REAR"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color2);
}else if ($data["zonename$j"] == "TRAILER RIGHT REAR"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color4);
}else if ($data["zonename$j"] == "TRAILER FRONT"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color5);
}else if ($data["zonename$j"] == "FRONT"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color6);
}else if ($data["zonename$j"] == "LF"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color7);
}else if ($data["zonename$j"] == "ENGINE"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color8);
}else if ($data["zonename$j"] == "RF"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color9);
}else if ($data["zonename$j"] == "INSIDE CAB"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color10);
}else if ($data["zonename$j"] == "LR"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color11);
}else if ($data["zonename$j"] == "RR"){
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color12);
}else{
$background[$a] = sprintf("bgcolor=\"%s\"", $this->color12);
}
}
}
Then the code is populated in another function
$reporthtml .= sprintf("<td><div class=\"idColumn\">%d</div></td>\n", $this->rowNumber($rownum));
$reporthtml .= sprintf("<td>%s</td><td>%s</td><td>%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td><td %s title=\"%s\">%s</td></tr>\n",
$data->inspType,
$data->assetName,
$data->inspID,
$background[$a],
$data->zonename1,
$data->timestamp1,
$background[$a],
$data->zonename2,
$data->timestamp2,
$background[$a],
$data->zonename3,
$data->timestamp3,
$background[$a],
$data->zonename4,
$data->timestamp4,
$background[$a],
$data->zonename5,
$data->timestamp5,
$background[$a],
$data->zonename6,
$data->timestamp6,
$background[$a],
$data->zonename7,
$data->timestamp7,
$background[$a],
$data->zonename8,
$data->timestamp8,
$background[$a],
$data->zonename9,
$data->timestamp9,
$background[$a],
$data->zonename10,
$data->timestamp10,
$background[$a],
$data->zonename11,
$data->timestamp11
);
$rownum++;
Currently all of the other information is populated but the backgrounds are not populating.
Any help would be great