Pesquisar na Comunidade
Mostrando resultados para as tags ''compra''.
Encontrado 1 registro
-
Ola Pessoal estou tendo um probleminha, consegui um tutorial de como montar um carrinho, que vou utilizar como pedidos no meu serviço. Esta funcionando normalmente, mas agora gostaria de saber como salvar os itens selecionados no banco. estou enviando o codigo da pagina pedidos. De ante mao muito obrigado por qualquer ajuda que me faça chegar a um resultado! pedidos.php <?php session_start(); if(!isset($_SESSION['carrinho'])){ $_SESSION['carrinho'] = array(); } //adiciona produto if(isset($_GET['acao'])){ //ADICIONAR CARRINHO if($_GET['acao'] == 'add'){ $id = intval($_GET['id']); if(!isset($_SESSION['carrinho'][$id])){ $_SESSION['carrinho'][$id] = 1; }else{ $_SESSION['carrinho'][$id] += 1; } } //REMOVER CARRINHO if($_GET['acao'] == 'del'){ $id = intval($_GET['id']); if(isset($_SESSION['carrinho'][$id])){ unset($_SESSION['carrinho'][$id]); } } //ALTERAR QUANTIDADE if($_GET['acao'] == 'up'){ if(is_array($_POST['prod'])){ foreach($_POST['prod'] as $id => $qtd){ $id = intval($id); $qtd = intval($qtd); if(!empty($qtd) || $qtd <> 0){ $_SESSION['carrinho'][$id] = $qtd; }else{ unset($_SESSION['carrinho'][$id]); } } } } } ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf8" /> <!--<link type="text/css" href="css/topo.css" rel="stylesheet"/> <link type="text/css" href="css/conteudo.css" rel="stylesheet"/> <link type="text/css" href="css/rodape.css" rel="stylesheet"/> <link type="text/css" href="css/estilo.css" rel="stylesheet" /> <script src="css/funcoes.js" type="text/javascript"></script>--> <script src="estudos.js" type="text/javascript"></script> <script src="../jquery-ui-1.11.4.custom/jquery-ui.js" type="text/javascript"></script> <script src="../jquery-ui-1.11.4.custom/jquery-ui.min.js" type="text/javascript"></script> <link type="text/css" href="../jquery-ui-1.11.4.custom/jquery-ui.css" rel="stylesheet"/> <link type="text/css" href="../jquery-ui-1.11.4.custom/jquery-ui.min.css" rel="stylesheet"/> <title>Listar Ferramentas</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href="../../favicon.ico"> <!-- Bootstrap core CSS --> <link href="../bootstrap-3.3.4-dist/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="../bootstrap-3.3.4-dist/css/navbar-fixed-top.css" rel="stylesheet"> <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]--> <script src="../bootstrap-3.3.4-dist/js/ie-emulation-modes-warning.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <!-- Fixed navbar --> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">SISCONFE</a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li class="divider"></li> <li class="dropdown-header">Nav header</li> <li><a href="#">Separated link</a></li> <li><a href="#">One more separated link</a></li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="../navbar/">Default</a></li> <li><a href="../navbar-static-top/">Static top</a></li> <li class="active"><a href="./">Fixed top <span class="sr-only">(current)</span></a></li> </ul> </div><!--/.nav-collapse --> </div> </nav> <div class="container"> <!-- Main component for a primary marketing message or call to action --> <div class="jumbotron"> <h1>SISCONFE</h1> <center><p>Sistema de Controle de Ferramentas e Estoque</p></center> <p> <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs »</a> </p> </div> </div> <!-- /container --> <div class="container"> <div class="row"> <div class="zero-clipboard"> <span class="btn-clipboard"><b>Seu Pedido:</b></span> </div> <div class="panel panel-info"> <div class="panel-body"> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>Pn/Sn</th> <th>Nome</th> <th>Quantidade</th> <th>Remover</th> </tr> </thead> <form action="?acao=up" method="POST"> <tfoot> <tr> <td colspan="4" > <input class="btn btn-success" type="submit" value="Atualizar Lista" /></td> </tr> <tr> <td colspan="4" ><a class="btn btn-info" href="listarprodutos.php">Escolher outra Ferramenta</a></td> </tr> </tfoot> <tbody> <?php if (count($_SESSION['carrinho']) == 0) { echo '<tr><td colspan="4" > Nenhuma Ferramenta Selecionada!</td></tr>'; }else{ include '../funcao_conexao.php'; foreach ($_SESSION['carrinho'] as $id => $qtd) { $qrPedido = mysql_query("SELECT * FROM tb_ferramenta WHERE FrCodigo= '$id'") or die(mysql_error()); $rowPedido = mysql_fetch_assoc($qrPedido); $SnPn = $rowPedido['FrSn'] ."/".$rowPedido['FrPn']; $Nome = $rowPedido['FrNome']; $CodFer = $rowPedido['FrCodigo']; $CodProj = $rowPedido['FrCodProjeto']; $CodOfi = $rowPedido['FrCodEspMnt']; echo ' <tr> <td>'.$SnPn.'</td> <td>'.$Nome.'</td> <td><input type"text" size="3" name="prod['.$id.']" value="'.$qtd.'"/></td> <td><a href="?acao=del&id='.$id.'"><img src="../imagens/delete36.png" border="0" alt="Remover" class="img-thumbnail"/></a></td> </tr>'; } $totalItens = 0; foreach ($_SESSION['carrinho'] as $id => $itemQTD) { $totalItens += $itemQTD; } echo ' <tr> <td colspan="2">Total de Ferramentas</td> <td colspan="2">'.$totalItens.'</td> </tr>'; $totalLinhas = count($_SESSION['carrinho']); } ?> </tbody> </table> </form> </div> </div> </div> </div> </div> </div> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../bootstrap-3.3.4-dist/js/jquery.min.js"></script> <script src="../bootstrap-3.3.4-dist/js/bootstrap.min.js"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="../bootstrap-3.3.4-dist/js/ie10-viewport-bug-workaround.js"></script> </body> </html>