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

如何在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 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色