duanfoumi5620 2012-12-05 19:17
浏览 58

使用PHP从每个TR获取第二个TD的值

I have a this table and I need to get the value of the second TD in a table row. Can I do this with PHP, and how can it be done?

This is my table:

<table class = "jshop cart">
  <tr class = "jshop_prod_cart odd">
    <td class = "jshop_img_description_center">
      <a href = "/shopping/index.php/product/view/210/3690">
        <img src = "http://localhost/shopping/components/com_jshopping/files/img_products/noimage.gif" alt = "test" class = "jshop_img" />
      </a>
    </td>
    <td style="text-align:left">
        FIRST VALUE I NEED                      
            </td>    
    <td>
        1 ден.            </td>
    <td>
      <input type = "text" name = "quantity[0]" value = "1" class = "inputbox" style = "width: 25px" />
    </td>
    <td>
        1 ден.            </td>
    <td>
      <a href = "/shopping/index.php/cart/delete?number_id=0" onclick="return confirm('Навистина сакате да го отстраните?')"><img src = "http://localhost/shopping/components/com_jshopping/images/remove.png" alt = "Отстрани" title = "Отстрани" /></a>
    </td>
  </tr>

  <tr class = "jshop_prod_cart even">
    <td class = "jshop_img_description_center">
      <a href = "/shopping/index.php/product/view/169/2876">
        <img src = "http://localhost/shopping/components/com_jshopping/files/img_products/thumb_3e28bb073e2ac2ca90345955ead6fc58.JPG" alt = "" class = "jshop_img" />
      </a>
    </td>
    <td style="text-align:left">
                 SECOND VALUE I NEED       

            </td>    
    <td>
        140 ден.            </td>
    <td>
      <input type = "text" name = "quantity[1]" value = "1" class = "inputbox" style = "width: 25px" />
    </td>
    <td>
        140 ден.            </td>
    <td>
      <a href = "/shopping/index.php/cart/delete?number_id=1" onclick="return confirm('Навистина сакате да го отстраните?')"><img src = "http://localhost/shopping/components/com_jshopping/images/remove.png" alt = "Отстрани" title = "Отстрани" /></a>
    </td>
  </tr>
    </table>
  • 写回答

4条回答 默认 最新

  • douwei8911 2012-12-05 19:20
    关注

    You can use a DOM parser such as Simple HTML DOM Parser like this:

    $ret = $html->find('td', 2);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算