Jump to content
Fórum Script Brasil
  • 0

Ajuda para atualizar qtd de item dinamicamente


sacofritoxd

Question

Ola pessoal. Gostaria de uma ajuda de vocês.

Estou armazenando os dados dos itens dentro de sessions nomeadas de produtos e qtd.

E cada item é separado do outro com um ";".

Mas estou tendo problemas para atualizar dinamicamente a qtd de cada item. Como eu poderia fazer isso com php?

O jeito que fiz no momento é assim, mas não funciona corretamente pois pega o ultimo item da table.

if ((count($qtd)) > 0){
                                for($i = 0; $i <= (count($qtd) -1); $i++){
                                        // ZEBRAR A TABELA
                                                if (($i % 2) == 0){
                                                        echo "<tr style='background-color: silver'>";
                                                }
                                                else{
                                                        echo "<tr style='background-color: white'>";
                                                }
                                                echo "<td><input type='hidden' name='item' value='$i'> $i</td>";
                                                echo "<td style='text-align:center'>"?><a href="confirmaitem.php?ad=1&removeitem=<?=$i?>" target="_self" title="Excluir"><img src="img/logo_excluir.png"></a> <? echo "</td>";
                                                unset($descricaoprod,$valorcheio,$valor_site);  
                                                $sql = "select descricao as descricaoprod, vl_venda as valorcheio, vl_site as valor_site from produtos where idprodutos=" . $produtos[$i];
                
                                                $db->select($sql);
                                                echo "<td> $descricaoprod[0]</td>";
                                                echo "<td> <input type='text' size='3' name='qtd$i' id='qtd$i' value=\"" . $qtd[$i] . "\"> "; ?><input type="image" src="img/ok.png" name="enviar" style="width: 20px; height: 20px"/>  <? echo "</td>";
                                                echo "<td>". number_format($valor_site[0], 2, ',','') . "</td>";
                                                echo "<td> ". number_format($qtd[$i] * $valor_site[0], 2, ',',' ')."</td>";
                                                $total = $total + ($qtd[$i] * $valor_site[0]);
                                                $total_itens = $total_itens + $qtd[$i];
                                                // FECHA LINHA DO PRODUTO
                                                echo "</tr>";
                                }
                        }

Neste site funciona do jeito que eu quero. já consegui fazer a deleção dos itens. Mas estou enrascado na auteração da qtd.

www.mesatenista.net/loja

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...