duanliang789262 2019-07-05 04:30
浏览 54

如何将.png图像作为背景添加到CodeIgniter的链接

I can't solve the problem.

I'm working on a PHP project with CodeIgniter, in the DisplayData views I have a table with data and in 2 columns I have links that when clicked call a function.

What I'm trying to do is use an image instead of links, ie set it as a link background.

I downloaded the image and inserted it in the folder where the views are (application/views/delete.png).

I tried to modify the CSS background-image: URL("basket.png"); but it doesn't work, I also tried to add the tag image

<a class=\"elimin\" href='deletedata?id=".$row-> id. "id> tag
<img src = "<? php echo base_url ('basket.png');?>
</a>

but he doesn't work either.

I also tried to write <img src = 'application/views/basket.png' /> but this doesn't work either

Can anyone tell me how can I do please?

DisplayData Views

echo "<tr>";
echo "<td> ".$row->id."</td>";
echo "<td>".$row->testo."</td>";
      echo "<input type=\"hidden\" name=\"myVariable\" value=\"'.$row->stato.'\"/><br/>";

      echo "<td>  Da fare </td>";


      echo "<td> 

<a class=\"modifica\" href='updatedata?id=".$row->id."'>Modifica</a>

</td>";

 //<input type='submit' name='update' value='Cancella'>

echo "<td><a class=\"elimina\" href='deletedata?id=".$row->id."'>
Elimina</a></td>";


  echo "</tr>";
  • 写回答

1条回答 默认 最新

  • dousiyou1058 2019-07-05 06:40
    关注

    First, you need a good folder structure. All the Images/JS/CSS/etc.. should be placed outside the application folder.

    application <== where the code placed
    assets  <== where all the Images/JS/CSS placed
       - images
       - css
       - js
    system <== system file
    index.php <== inedx file
    

    Then below code will work

    <img src="<?php echo base_url() ?>assets/images/basket.png"/>
    

    FYI

    In view no need to use echo all the time. you can just remove <?php from top of the file and just use HTML's. If you need anything with PHP just wrap those only with <?= ?>(PHP short tag must be enabled) or <?php echo ?>

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向