gpt4 book ai didi

php - 在 php 中使用三元运算符根据 sql 中的事件状态回显不同的状态

转载 作者:行者123 更新时间:2023-11-28 18:29:03 25 4
gpt4 key购买 nike

好吧,如果状态为 1,则为“有效保险事件”,如果为 2,则为“已完成保险事件”。

if(!empty($ins_event))
{
echo "<tr><td>&nbsp;<img src='/check-icon.gif'> <a href='". matry::here(array('event_id'=>$ins_event['id'])) . "'>" . ( $ins_event['status'] == 2 ? "Completed Insurance Event": "Active Insurance Event") . "</a></td></tr>";
}
else
{
echo "<tr><td>" . cbox_return() . "<a href='". matry::here_to('new', array('tfilt'=>'IN', 'pfilt'=>$patient->code)) . "' style='color: #000; color:$rx_image_color'>**Ins Event Not Created**</td></tr>";
}

我这里有一个颜色变量:

<?php
$rx_event_colors = $rx_ev_status = '#009933';
?>

我如何使用这个变量来获取 2 的状态并更改字体颜色。

我应该分解脚本并使用 if {} else {} 语句吗?


更新代码:

echo "<tr><td>&nbsp;<img src='/check-icon.gif'> <a href='". matry::here(array('event_id'=>$ins_event['id'])) . "'" . ( $ins_event['status'] == 2 ? ' style="color: ' . $rx_ev_status . '">Completed Insurance Event' : '>Active Insurance Event') . "</a></td></tr>"; 

最佳答案

你基本上会做同样的三元运算:

($ins_event['status'] == 2 ? ' style="color: ' . $rx_ev_status . '"' : '')

关于php - 在 php 中使用三元运算符根据 sql 中的事件状态回显不同的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14844292/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com