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 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动