根据值更改背景颜色

时间:2017-10-16 14:02:03

标签: php html css

我正在尝试这个,但似乎对我不起作用。我参考了here。以下是我的代码:

$today = date('Y-m-d');
$date = new DateTime();

$R1D2 = $date->setISODate($year,$week,1)->format('Y-m-d');

<td width="14.285%" <?php if ($R1D2 = $today): ?> style="background:#EEEEEE" <?php endif ?>>some content here </td>

结果是,所有单元格都会改变其背景,即使它与$today不相等

1 个答案:

答案 0 :(得分:5)

$R1D2

您实际上将$today设为if ($R1D2 == $today):。请将该行更改为:

{{1}}