We help IT Professionals succeed at work.

php and colouring cells

doctorbill
doctorbill asked
on
98 Views
Last Modified: 2019-01-04
 <?php while ($row = $results->fetch_assoc()):$style = "";
  //if ($row['frm_id'] < "5"){
    //$style2 = "style='background:#FF0000;'";
  //} 
                  
  //if ($row['frm_id'] > "5"){
    //$style2 = "style='background:#FFF000;'";
  //} 
         //if ($row['frm_id'] =="5"){
    //$style2 = "style='background:#ddd000;'";
  //} 
       $data_new = $row['radnew'];
       $data_progress = $row['radinprogress'];
        $data_closed = $row['radclosed'];
       
    
if (isset ($row['radnew'])) {
    $style2 = "style='background:#ddd000;'";
}
      else if (isset ($row['radinprogress'])){
    $style3 = "style='background:#FFa500;'";
}
         else if (isset ($row['radclosed'])){
    $style4 = "style='background:rgb(255,100,0);'";
}
       
        
?>

                <table id="customers">
                 <tr>
                  <th>ID:</th>
                  <th>Company:</th>
                  <th>Contact:</th>
                  <th>Ticket Status:</th>
                     <th>Ticket Status:</th>
                     <th>Ticket Status:</th>
                 </tr>
                
                    <tr>
                        <td><?= $row['sup_id'] ?>&nbsp;<?php echo "<a href=\"searchWorkformSitesDateStatus.php?id=" . $row['sup_id'] ."\" target=\"_blank\">RecordLink... </a>"; ?></td>
                        <td><?= $row['sup_company'] ?></td>
                        <td><?= $row['sup_contact'] ?></td>
                        <td <?php echo $style2 ?>><?= $row['radnew'] ?></td>
                        <td <?php echo $style3 ?>><?= $row['radinprogress'] ?></td>
                        <td <?php echo $style4 ?>><?= $row['radclosed'] ?></td>
                        
                    </tr>
        </table>
                
      
            <?php endwhile; ?>

Open in new window


In the above code I am trying to colour individual cells if they have a value set
Whai is happening at the moment is that cells are coloured but empty cells as well as cells with values set (seel attached file)
I am also getting an undefined variable error
Where am I going wrong with this please
Capture.PNG
Comment
Watch Question

Author

Commented:
Solution:

if (empty ($row['radnew'])) {
    $style2 = "style='background:#ffffff;'";
}
        else {
            $style2 = "style='background:#ddd000;'";
        }
       if (empty ($row['radinprogress'])){
    $style3 = "style='background:#FFFFFF;'";
}
        else {
            $style3 = "style='background:#FFa500;'";
        }

etc.......

Author

Commented:
finished
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.