我正在处理以下代码。我需要在表中添加每个类别的所有值。数据来自数据库。请先看图片:这是我的HTML代码:<table id="data" class="table table-bordered table-striped"> <thead> <tr align="center"> <th width="5%">Item</th> <th width="30%">Description</th> <th width="5%">Unit</th> <th width="5%">Qty</th> <th width="10%">Unit Cost</th> <th width="15%">Amount</th> </tr> </thead> <tbody> <tr> <td>1</td> <td colspan="5"><i>General Requirement</i></td> </tr> <?php $id = $_GET['id']; $select_bill = "SELECT *, quantity * unit_cost AS amount FROM bill_tbl WHERE project_name = $id"; $select_bill_result = mysqli_query($con,$select_bill); if (mysqli_num_rows($select_bill_result)> 0) { while ($row = mysqli_fetch_assoc($select_bill_result)) { if ($row['category'] == 'General Requirement') { ?> <tr> <td></td> <td><?php echo $row['description']; ?></td> <td><?php echo $row['unit']; ?></td> <td><?php echo $row['quantity']; ?></td> <td><?php echo $row['unit_cost']; ?></td> <td><?php echo $row['amount']; ?></td> </tr> <?php } } } ?> <tr> <td></td> <td colspan="4"><b>Subtotal</b></td> <td></td> </tr> <tr> <td>2</td> <td colspan="5"><i>Concrete and Masonry Works</i></td> </tr>这是我学校的项目。
3 回答
- 3 回答
- 0 关注
- 381 浏览
添加回答
举报
0/150
提交
取消