0
I’m having trouble saving a list of items on ArrayInterator
, where I need to save this data to the table by clicking 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;?>
your code makes no mention of saving data in the database, can you include the part of code in which you try to write that data? It may be that the function serialize() solve the problem.
– Pedro Sanção
Actually I haven’t done it yet, because I don’t know what to do... I just need how to do it. help me @Sanction
– Renan Rodrigues
you are trying to save in the database the request that is in the session? if yes, save the
ArrayIterator
is not the best way to do.– Pedro Sanção
Type, because this will work as a shopping cart, where I will make the purchase of the determined items, soon after I enter the cart page, and click on make purchase. This stop to make purchase I want, however I’m not doing online store, but follows this idea.
– Renan Rodrigues