基于sql位值创建自定义html内容.null,0,1


Creating custom html content based on a sql bit value. null, 0, 1

如果没有图像,它会返回文件上没有Rx,这很好。如果有图像,它会在蓝色链接中返回Rx Requires Validation。当上传图像时,它是一个0,当它被选择为活动时,它将变为1,作为数据库中的活动字段。我不知道如何将所有图像都设为0蓝色,而现在将活动图像设为1绿色。我想我的逻辑在这一点上已经完全崩溃了。。任何帮助都将不胜感激。

if ($a['rx_scanned'] === null)
    {
         echo "<tr><td>**No Rx on File**</td></tr>"; 
    }

elseif ($a['rx_scanned'] = 1 ) 
    {
  $rx_image_color = '#009933';
    echo "<tr><td> &nbsp;<img src='http://sqlserver/test/tim/leaflet/check-icon.gif'>&nbsp;<a href='" 
            . matry::base_to('patient/image/view', array('event_id'=>$event->id, 'patient_id'=>$patient->code, 'uniqueid'=>$a['image_id'])) 
            . "' style='color:$rx_image_color'>Valid Rx on File</a></td></tr>"; 
    }
else   
    { 
      $rx_image_color = '#3366FF';
      echo "<tr><td>" . cbox_return($name) . "<a href='" 
            . matry::base_to('patient/image/view', array('event_id'=>$event->id, 'patient_id'=>$patient->code, 'uniqueid'=>$a['image_id'])) 
            . "'>**Rx Requires Validation**</a></td></tr>"; 
    }   
echo "<tr><td></td></tr>";

如果我理解正确的话,你说rx_scanted是一个布尔值,而不是数字。

您需要更改条件以检查布尔值(我不是PHP开发人员,但我想是这样的)

if ($a['rx_scanned']) {
  $rx_image_color = '#009933';
   // Insert your stuff here.
}
else {
  $rx_image_color = '#3366FF';
  echo "<tr><td>**No Rx on File**</td></tr>";
}