dsfs23434 2017-08-14 05:08
浏览 461
已采纳

如何在PHP代码中使用<td>里面的div标签

I want to know how should we use div tags inside a table in PHP code. This is my code. Please tell me how to use it properly.

<tbody>
    <?php
    $result = mysqli_query($conn,$sql);
    while($row = mysqli_fetch_array($result,MYSQLI_BOTH)) {  

        echo "<tr>

        <td>{$row['id']}</td>
        <td><img  width='90px' height='90px' src='imageView.php?id=".$row["id"]."' /> </td>
        <td>{$row['item_name']}</td>
        <td>{$row['description']}</td>
        <td>{$row['quantity']}</td>
        <td>echo '<div class="col-md-1 col-sm-3 col-xs-6 c-cart-qty">

            <div class="c-input-group c-spinner">
                <input type="text" class="form-control c-item-1" value="1">
                <div class="c-input-group-btn-vertical">
                    <button class="btn btn-default" type="button" data_input="c-item-1">
                        <i class="fa fa-caret-up"></i>
                    </button>
                    <button class="btn btn-default" type="button" data_input="c-item-1">
                        <i class="fa fa-caret-down"></i>
                    </button>
                </div>
            </div>
        </div> 
        </td>';                                                 
        <td> <button>submit</button>  </td>

        </tr>";


    }?>
</tbody>

I have tried using inverted comma's and braces but still, it shows error. What needs to be done here?

  • 写回答

2条回答 默认 最新

  • dongtuoji5396 2017-08-14 05:15
    关注

    You can write the div inside table. Don't put all table inside php tag. remove html outside the <?php ?> php code. after that whenever you want to echo any value just used the php.

    Customize your code like below,

    <table>
        <tbody>
            <?php
            $result = mysqli_query($conn, $sql);
            while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
                ?>
                <tr>
                    <td><?php echo $row['id']; ?></td>
                    <td><img  width='90px' height='90px' src='imageView.php?id=<?php echo $row["id"]; ?>' /> </td>
                    <td><?php echo $row['item_name']; ?></td>
                    <td><?php echo $row['description']; ?></td>
                    <td><?php echo $row['quantity']; ?></td>
                    <td>
                        <div class="col-md-1 col-sm-3 col-xs-6 c-cart-qty">
    
                            <div class="c-input-group c-spinner">
                                <input type="text" class="form-control c-item-1" value="1">
                                <div class="c-input-group-btn-vertical">
                                    <button class="btn btn-default" type="button" data_input="c-item-1">
                                        <i class="fa fa-caret-up"></i>
                                    </button>
                                    <button class="btn btn-default" type="button" data_input="c-item-1">
                                        <i class="fa fa-caret-down"></i>
                                    </button>
                                </div>
                            </div>
                        </div> 
                    </td>                                             
                    <td> <button>submit</button>  </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 CSS实现渐隐虚线边框
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题