我需要一些帮助,我如何能从sql软查询。我有一个php脚本与html页面谁是显示从查询的结果。
我有这样的查询:
$ready_orders = DB::query( 'SELECT * FROM ordertable where orderid is NOT null ORDER by id DESC')->fetchAll( DB::FETCH_ASSOC );
从HTML我有这个;
<tal:block tal:condition="exists:orders">
<table>
<tr>
<td>amount</td>
<td> want counter here</td>
<td>result 1</td>
<td>result 2</td>
<td>result 3</td>
<td>result 4</td>
</tr>
<tr tal:repeat="order orders">
<td tal:content="">
....
</td>
<td tal:content="order/id">
....
</td>
<td tal:content="order/orderid">
....
</td>
<td tal:content="order/productid">
....
</td>
<td tal:content="order/processed">
....
</td>
<td>
</td>
</tr>
</table>
查询是做所有我想要的,但需要的结果是在一个清单。如计数器1、2、3、4、5等
有可能吗?
include
select count * from ordertable
然后将结果插入到第一个
SELECT COUNT(orderid) AS Order_Count
FROM ordertable
WHERE orderid IS NOT NULL
using foreach loop
<tal:block tal:condition="exists:orders">
<table>
<tr>
<td>amount</td>
<?php
$i = 1;
foreach($ready_orders as $result){ ?>
<td>result <?php echo $i++; ?></td> //your counter
<?php } ?>
</tr>
<tr tal:repeat="order orders">
<td tal:content="">
....
</td>
<td tal:content="order/id">
....
</td>
<td tal:content="order/orderid">
....
</td>
<td tal:content="order/productid">
....
</td>
<td tal:content="order/processed">
....
</td>
<td>
</td>
</tr>