doufu1504 2013-01-28 21:54
浏览 32

php if elseif自定义样式[关闭]

i trying to make shipping method with custom css style in opencart cms.

default code in this section is:

<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>

All ok in this code, and i get three links: Shipping post, take own in the shop, Courier.

ok, i wanna make custom style in each link custom style. I'm trying:

  <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>

but i get from three differents links, three same links: 1 link, 1 link, 1 link. Then i wanna to have: 1 link, 3 link, 3 link

Maybe i using wrong code? Please help.

  • 写回答

1条回答 默认 最新

  • duanchi19820419 2013-01-28 21:55
    关注
    <?php } elseif ($quote['title'] = $atsiemimas) {?>
    <font style="color:red;">2 link</font>
    <?php } elseif ($quote['title'] = $vienetas) {?>
    

    should be:

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

    You use a singe "=", so instead of comparing, you set te variable.

    评论

报告相同问题?

悬赏问题

  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False