Increase in DataTable

2

I have this dataTable with a best-selling product top, but I do not want to give me the id of the table, but a loop from 1 to 10, how could I do it? Here I have my code:

<table class="table table-bordered table-hover table-striped">
  <thead>
    <tr>
      <th>#</th>
      <th>Nombre</th>
      <th>Categoria</th>
    </tr>
  </thead>
  <tbody>
    <?php if(!empty($productosmvendidos)):?>
      <?php foreach($productosmvendidos as $pmv):?>
        <tr>
          <?php $i=1;?>
          <td><?php echo $i+=1;?></td>
          <td><?php echo $pmv->nombre;?></td>
          <td><?php echo $pmv->categoria;?></td>
        </tr>
      <?php endforeach;?>
  <?php endif;?>
  </tbody>
</table>

Here the table:

Thank you very much already.

    
asked by WilsonicX 30.08.2018 в 16:42
source

1 answer

0

I already solved it, thanks @Rastalovely I leave the answer here:

<table class="table table-bordered table-hover table-striped">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>Nombre</th>
                                <th>Categoria</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(!empty($productosmvendidos)):?>
                                <?php $i=1;?>
                                <?php foreach($productosmvendidos as $pmv):?>
                                    <tr>
                                        <td><?php echo $i++;?></td>
                                        <td><?php echo $pmv->nombre;?></td>
                                        <td><?php echo $pmv->categoria;?></td>

                                    </tr>
                                <?php endforeach;?>
                            <?php endif;?>
                        </tbody>
                    </table>

    
answered by 30.08.2018 в 16:56