I'm having trouble saving a list of items in ArrayInterator
, where I need to save this data in the table when I click a save button.
Array code:
<?php
...
$p = new ArrayIterator($_SESSION['PEDIDO']);
while ($p->valid()):
//$p->key(); Utilizado para pegar os ids.
//$p->current(); Pega a quantidade de produtos por ids.
$c = new Carrinho;
$c->setId($p->key());
$pedido = $c->listarPedidos();
?>
<tr>
<td><?php echo $p->key(); ?></td>
<td><?php echo $pedido->NMPRODRUTO; ?></td>
<td>R$ <?php echo number_format($pedido->VLVENDA,2,",","."); ?></td>
<td align="center"><input type="text" id="qtde" value="<?php echo $p->current(); ?>" data-id="<?php echo $p->key(); ?>" data-preco="<?php echo $pedido->VLVENDA; ?>"/></td>
<td align="center" id="subtotal">R$ <?php echo number_format(($pedido->VLVENDA*$p->current()),2,",",".") ?></td>
<td align="center"><a href="?delete=ok&id=<?php echo $p->key(); ?>"><img src="img/deletar.png" id="excluir" /></a></td>
</tr>
<?php
$p->next();
endwhile;?>