作者lcy17 (Aoie)
看板PHP
标题[请益] 正确回圈方法?
时间Tue Apr 18 16:58:33 2017
各位前辈好
我有做个订单资讯
我目前的code会使总资讯出现在每一笔细项的下方
如果我只想一笔订单出现一次总资讯
请问我的做法要怎麽改呢?
我目前有想到foreach
可是条件式 as 那边不知道要怎麽放
图片是长这样 应该知道我在说什麽了吧QQ
http://i.imgur.com/agCkAGB.jpg
<?php while ($drow = $drs->fetch_assoc()): ?>
<table class="rwd-table table-bordered table-responsive">
<tr >
<th>订单编号</th>
<th>商品明细</th>
<th>数量</th>
<th>价格</th>
</tr>
<tr>
<td data-th="订单编号" class="product-num"><?=
$drow['sid'] ?></td>
<td data-th="商品明细" class="product"><p><?=
$drow['product_name'] ?></p></td>
<td data-th="数量" class="product-howmany"><p><?=
$drow['qty'] ?></p></td>
<td data-th="价格" class="product-price"><p><?=
$drow['price'] ?></p></td>
</tr>
</table>
<div class="total">
<p>共 <?= $drow['totalqty'] ?> 项产品</p><br>
<p>总金额: <?= $drow['total'] ?></p>
<p>配送方式:<?= $drow['delivery'] ?></p>
<p>付款方式:<?= $drow['payment'] ?></p>
<p>寄送地址:<?= $drow['address'] ?></p><br>
</div>
<?php endwhile; ?>
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 125.227.255.81
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/PHP/M.1492505916.A.FD3.html
※ 编辑: lcy17 (111.71.32.196), 04/18/2017 18:44:29
1F:→ imhaha: 把表单拉掉? 看不太懂你的意思每笔订单只秀一个总资讯(总金额那块) 可是每笔订单会有不只ㄧ项产品
※ 编辑: lcy17 (111.71.32.196), 04/18/2017 19:29:30
2F:→ Phedra: total 那一列通常不会写在回圈里,而是独立在回圈结束後才 04/19 00:09
3F:→ Phedra: 处理。 04/19 00:09
4F:→ Phedra: 1. 先用回圈显示每项产品 (同时间可以先计算总额但不显示) 04/19 00:10
5F:→ Phedra: 2. 回圈结束之後,再接着处理并显示 total 那一行 04/19 00:11