4

I need some help with how I can soft query from sql. I have a php script with an html page who is showing the result from the query.

I have this query:

 $ready_orders = DB::query( 'SELECT * FROM ordertable where orderid is NOT null ORDER by id DESC')->fetchAll( DB::FETCH_ASSOC ); 

From the HTML I have this;

<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>

The query is doing all I want, but need the result to be in a listing. Like a counter 1,2,3,4,5 etc

Is it possible?

Denis C de Azevedo
  • 6,276
  • 2
  • 32
  • 49

3 Answers3

0

include a

select count * from ordertable

Then insert this result in the first

Etcetera
  • 130
  • 14
0
SELECT COUNT(orderid) AS Order_Count
FROM ordertable
WHERE orderid IS NOT NULL
Andy
  • 55
  • 1
  • 9
0

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>

Ghulam Ali
  • 357
  • 4
  • 17
  • Sill not working. Im not so good with the php tal. It wright the query as array. I think i need to put something in the phptal that doest not call to an array – user3592679 Aug 26 '15 at 15:50
  • amount want counter here result 1 result 2 result 3 result 4
    .... .... .... .... ....
    – user3592679 Aug 26 '15 at 15:52
  • Not responding on this. The hole query i have is this: protected $template = 'order.felix'; public function Execute(){ $ready_orders = DB::query( 'SELECT * FROM order_felix WHERE orderid IS NOT NULL')->fetchAll( DB::FETCH_ASSOC ); $this->orders = $ready_orders; – user3592679 Aug 26 '15 at 16:24