Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/09/2014, 10:59
quintana_jairo
 
Fecha de Ingreso: agosto-2014
Mensajes: 21
Antigüedad: 9 años, 8 meses
Puntos: 0
Problemas con insert

Hola Tengo un problema en php quiero subir los valores nota y valor a la base de datos pero cuando le coloco al insert into el valor, nota y ejecuto la web no me sale nada es decir no hace ninguna funcion

Código PHP:
Ver original
  1. <?php
  2.     session_start();
  3.         include('php_conexion.php');
  4.         $act="0";
  5.     include_once("php_conexion.php");
  6.     if(!empty($_GET['del'])){
  7.         $id=$_GET['del'];
  8.         mysql_query("DELETE FROM carrito WHERE codigo='$id'");
  9.     }
  10.        if(!$_SESSION['tipo_usu']=='a' or !$_SESSION['tipo_usu']=='ca'){
  11.             header('location:index.php');
  12.  
  13.  
  14.         }
  15.     ?>
  16.  
  17. <!DOCTYPE html>
  18. <html lang="es">
  19.   <head>
  20.     <meta charset="utf-8">
  21.     <title>Carrito de Compras</title>
  22.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  23.     <meta name="description" content="">
  24.     <meta name="author" content="">
  25.  
  26.     <!-- Le styles -->
  27.     <link href="css/bootstrap.css" rel="stylesheet">
  28.     <style type="text/css">
  29.       body {
  30.         padding-top: 60px;
  31.         padding-bottom: 40px;
  32.       }
  33.     </style>
  34.     <link href="css/bootstrap-responsive.css" rel="stylesheet">
  35.  
  36.     <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  37.     <!--[if lt IE 9]>
  38.       <script src="../assets/js/html5shiv.js"></script>
  39.     <![endif]-->
  40.  
  41.     <!-- Fav and touch icons -->
  42.  
  43.     <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
  44.     <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  45.       <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
  46.                     <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
  47.                                    <link rel="shortcut icon" href="ico/favicon.png">
  48.   </head>
  49.  
  50.   <body>
  51.  
  52.     <div class="navbar navbar-inverse navbar-fixed-top">
  53.       <div class="navbar-inner">
  54.         <div class="container">
  55.           <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  56.             <span class="icon-bar"></span>
  57.             <span class="icon-bar"></span>
  58.             <span class="icon-bar"></span>
  59.           </button>
  60.           <a class="brand" href="#">Tienda Venezuela Computer</a>
  61.           <div class="nav-collapse collapse">
  62.             <ul class="nav">
  63.               <li class="active"><a href="index.php">Principal</a></li>
  64.               <li><a href="mis_pedidos.php">Mis Pedidos</a></li>
  65.             </ul>
  66.  
  67.             </li>
  68.             <table width="200" border="2" align="right">
  69.               <tr>
  70.                 <td bgcolor="#FFFFFF"><a href="#" id="drop3" role="button" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user"></i> Hola! <?php echo $_SESSION['username']; ?> <b class="caret"></b></a>
  71.               <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
  72.                 <li role="presentation"><a role="menuitem" tabindex="-1" href="cambiar_clave.php" target="admin"><i class="icon-refresh"></i> Cambiar Contraseña</a></li>
  73.                 <li role="presentation" class="divider"></li>
  74.                 <li role="presentation"><a role="menuitem" tabindex="-1" href="php_cerrar.php"><i class="icon-off"></i> Salir</a></li></td>
  75.               </tr>
  76.             </table>
  77.           </div><!--/.nav-collapse -->
  78.           </a>
  79.         </div>
  80.       </div>
  81.     </div>
  82.  
  83.     <div class="container">
  84.  
  85.       <!-- Main hero unit for a primary marketing message or call to action -->
  86.       <div class="hero-unit" align="center">
  87.             <p><img src="file:///C|/Users/Secretaria/Desktop/Nueva carpeta/images/slogan-bg.jpg" class="img-polaroid"></p>
  88.  
  89.       </div>
  90.  
  91.       <!-- Example row of columns -->
  92.       <div class="row">
  93.  
  94.       </div>
  95.       <div align="center">
  96.  
  97.         <div class="row-fluid">
  98.             <div class="span8">
  99.             <?php
  100.                 $pa=mysql_query("SELECT * FROM producto where estado='s'");            
  101.                 while($row=mysql_fetch_array($pa)){
  102.             ?>                      
  103.             <table class="table table-bordered">
  104.                 <tr><td>
  105.                     <div class="row-fluid">
  106.                         <div class="span4">
  107.                             <center><strong><?php echo $row['nombre']; ?></strong></center><br>
  108.                             <img src="img/producto/<?php echo $row['codigo']; ?>.jpg" class="img-polaroid">
  109.                         </div>
  110.                         <div class="span4"><br><br><br><br>
  111.                             <strong><?php echo $row['nota']; ?></strong><br><br>
  112.                             <strong>Valor: </strong>$ <?php echo number_format($row['valor'],2,",","."); ?>
  113.                         </div>
  114.                         <div class="span4"><br><br><br><br><br>
  115.                             <form name="form<?php $row['codigo']; ?>" method="post" action="">
  116.                                 <input type="hidden" name="codigo" value="<?php echo $row['codigo']; ?>">
  117.                                 <button type="submit" name="boton" class="btn btn-primary">
  118.                                
  119.                              
  120.                                     <i class="icon-shopping-cart"></i> <strong>Agregar al Carrito</strong>
  121.                                    
  122.                                 </button>
  123.                                 <p>&nbsp;</p>
  124.                                 <font color="red"><strong>Existencia: </strong> <?php echo number_format($row['existencia']); ?>
  125.                             </form>
  126.                         </div>
  127.                     </div>
  128.                 </td></tr>
  129.             </table>
  130.             <?php } ?>
  131.             </div>
  132.             <div class="span4">
  133.   <?php
  134.                 if(!empty($_POST['codigo'])){
  135.                     $codigo=$_POST['codigo'];
  136.                     $nota=$row['nota'];
  137.                     $pa=mysql_query("SELECT codigo, cantidad FROM carrito WHERE usu = '" . $_SESSION["username"] . "' AND codigo = '". $codigo . "'" );            
  138.                     if($row=mysql_fetch_array($pa)){
  139.                         $new_cant=$row['cantidad']+1;
  140.                         mysql_query("UPDATE carrito SET cantidad =  '" . $new_cant . "' WHERE usu = '" . $_SESSION["username"] . "' AND codigo =  '" . $codigo . "'");
  141.                     }else{
  142.                         mysql_query("INSERT INTO carrito (codigo, cantidad, usu) VALUES('" . $codigo . "', '1', '" . $_SESSION["username"] . "')");
  143.                     }
  144.                 }
  145.             ?>
  146.              <div id="sidebar"><br><br><br>
  147.                     <h2 align="center">Mis Pedidos</h2>
  148.                     <table class="table table-bordered">
  149.                       <tr>
  150.                         <td height="153">
  151.                             <table class="table table-bordered table table-hover">
  152.                             <?php
  153.                                 $neto=0;$tneto=0;
  154.                                 $pa=mysql_query("SELECT * FROM carrito WHERE usu = '". $_SESSION["username"] ."'");        
  155.                                 while($row=mysql_fetch_array($pa)){
  156.                                     $oProducto=new Consultar_Producto($row['codigo']);
  157.                                     $neto=$oProducto->consultar('valor')*$row['cantidad'];
  158.                                     $tneto=$tneto+$neto;
  159.  
  160.                             ?>
  161.                               <tr style="font-size:9px">
  162.                                 <td><?php echo $oProducto->consultar('nombre'); ?></td>
  163.                                 <td><?php echo $row['cantidad']; ?></td>
  164.                                 <td>$ <?php echo number_format($neto,2,",","."); ?></td>
  165.                                 <td>
  166.                                     <a href="index.php?del=<?php echo $row['codigo']; ?>" title="Eliminar de la Lista">
  167.                                         <i class="icon-remove"></i>
  168.                                     </a>
  169.                                 </td>
  170.                               </tr>
  171.                             <?php }
  172.                             ?>
  173.                                 <td colspan="4" style="font-size:9px"><div align="right">$<?php echo number_format($tneto,2,",","."); ?></div></td>
  174.                             <?php
  175.                                 $pa=mysql_query("SELECT * FROM carrito WHERE usu = '". $_SESSION["username"] ."'");        
  176.                                 if(!$row=mysql_fetch_array($pa)){
  177.                             ?>
  178.                               <tr><div class="alert alert-success" align="center"><strong>No hay Productos Registrados</strong></div></tr>
  179.                               <?php } ?>
  180.                             </table></td>
  181.                       </tr>
  182.                     </table>
  183.                 </div>
  184.             </div>
  185.         </div>
  186.  
  187.       </div>
  188.  
  189.       <hr>
  190.  
  191.       <footer>
  192.         <p>&copy; Venezuela Computer 2014</p>
  193.         <p>&nbsp;</p>
  194.  
  195.       </footer>
  196.  
  197.     </div> <!-- /container -->
  198.  
  199.         $(function() {
  200.             var offset = $("#sidebar").offset();
  201.             var topPadding = 15;
  202.             $(window).scroll(function() {
  203.                 if ($("#sidebar").height() < $(window).height() && $(window).scrollTop() > offset.top) { /* LINEA MODIFICADA POR ALEX PARA NO ANIMAR SI EL SIDEBAR ES MAYOR AL TAMAÑO DE PANTALLA */
  204.                     $("#sidebar").stop().animate({
  205.                         marginTop: $(window).scrollTop() - offset.top + topPadding
  206.                     });
  207.                 } else {
  208.                     $("#sidebar").stop().animate({
  209.                         marginTop: 0
  210.                     });
  211.                 };
  212.             });
  213.         });
  214.     </script>
  215.  
  216.   </body>
  217. </html>