PHP 如果 elseif 自定义样式


php if elseif custom style

我试图在Opencart CMS中使用自定义CSS样式制作运输方法。

本节中的默认代码为:

<tr class="highlight">
<td><?php if ($quote['code'] == $code || !$code) { ?>
  <?php $code = $quote['code']; ?>
  <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" id="<?php echo $quote['code']; ?>" checked="checked" />
  <?php } else { ?>
  <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" id="<?php echo $quote['code']; ?>" />
  <?php } ?></td>
<td><label for="<?php echo $quote['code']; ?>"><?php echo $quote['title']; ?></label></td>
<td style="text-align: right;"><label for="<?php echo $quote['code']; ?>"><?php echo $quote['text']; ?></label></td>

这段代码都没问题,我得到了三个链接:运输邮政,在商店自己,快递。

好的,我想在每个链接中自定义样式。我在努力:

  <tr class="highlight">
<td><?php if ($quote['code'] == $code || !$code) { ?>
  <?php $code = $quote['code']; ?>
  <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" id="<?php echo $quote['code']; ?>" checked="checked" />
  <?php } else { ?>
  <input type="radio" name="shipping_method" value="<?php echo $quote['code']; ?>" id="<?php echo $quote['code']; ?>" />
  <?php } ?></td>
<td><label for="<?php echo $quote['code']; ?>">
<?php $pastas = 'Shipping post'; ?>
<?php $atsiemimas = 'Courier'; ?>
<?php $vienetas = 'take own in the shop'; ?>
<?php if ($quote['title'] = $pastas) { ?>
    <font style="color:red;">1 link</font>
<?php } elseif ($quote['title'] = $atsiemimas) {?>
<font style="color:red;">2 link</font>
<?php } elseif ($quote['title'] = $vienetas) {?>
<font style="color:red;">3 link</font>
<?php }?>
</label></td>
<td style="text-align: right;"><label for="<?php echo $quote['code']; ?>"><?php echo $quote['text']; ?></label></td>

但我从三个不同的链接,三个相同的链接得到:1个链接,1个链接,1个链接。然后我想有:1

个链接,3个链接,3个链接

也许我使用了错误的代码?请帮忙。

<?php } elseif ($quote['title'] = $atsiemimas) {?>
<font style="color:red;">2 link</font>
<?php } elseif ($quote['title'] = $vienetas) {?>

应该是:

<?php } elseif ($quote['title'] == $atsiemimas) {?>
<font style="color:red;">2 link</font>
<?php } elseif ($quote['title'] == $vienetas) {?>

使用一个单一的"=",所以你不是比较,而是设置te变量。