Table Cell bgcolor change depending on database value

christye1224 16 Jan, 2011
I'm trying to get my chronoconnect table to show certain cells in different colors based on the value of a checkbox checked in my chronoform, but I can't seem to get it to function.

Here's a relevant snippet of the table in my chronoconnectivity page:
<table border="1">
<?php
$check0 = $row["check0"];
?>
<?php
if ($check0==0)
    {
        $rowcolor = "white";
    }
elseif ($check0==1)
    {
        $rowcolor = "yellow";
    }
elseif ($check0==2)
    {
        $rowcolor = "orange";
    }
else
    {
        $rowcolor = "white";
    }
?> 
 <tr name="employee1"> 
    <td bgcolor="<? echo($rowcolor); ?>"><div class="form_item">
  <div class="form_element cf_dropdown">
{emp1select}
  </div>
</div><div class="form_item">
  <div class="form_element cf_checkbox">
    <label class="cf_label" style="width: 150px;"></label>
    <div class="float_left">
{check0}
      <br />
     
    </div>
    
  </div>
</div></td></tr><table>


What am I missing? Or am I completely off-base with this code?

Also, at the moment, I have the chronoconnectivity table displaying the value for the checkbox selection ({check0}). How do I "hide" that? Essentially, I just want the value to effect the color of the cell, not to publish the actual value..

Thanks in advance🙂
GreyHead 17 Jan, 2011
Hi christye1224,

Replace
$check0 = $row["check0"];
with
$check0 = $MyRow->check0;

Bob
christye1224 17 Jan, 2011
Excellent! It works, thank you.🙂 I may have some other questions as I proceed here- yet another task (for the same project I was working on previously and had questions on) that isn't quite the norm, I'm afraid, Bob. lol. I'm slowly getting the hang of things, but sometimes it's helpful to have a fresh pair of eyes look over things to figure out where my errors are.😉

Thanks again, Bob.🙂
This topic is locked and no more replies can be posted.