elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
41  Programación / PHP / Re: problemas al ingresar datos con php en: 17 Julio 2014, 21:37 pm
bueno ve acabo de modificar todo mira como lo tengo

conexion.php

Código
  1. <?php
  2. $conexion = mysql_connect("localhost", "root", "") or trigger_error(mysql_error(),E_USER_ERROR);
  3. mysql_select_db("carrito", $conexion);
  4. ?>


funciones.php

Código
  1. <?php
  2. function getParam($param, $default) {
  3. $result = $default;
  4. if (isset($param)) {
  5.   $result = (get_magic_quotes_gpc()) ? $param : addslashes($param);
  6. }
  7. return $result;
  8. }
  9. function sqlValue($value, $type) {
  10.  $value = get_magic_quotes_gpc() ? stripslashes($value) : $value;
  11.  $value = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($value) : mysql_escape_string($value);
  12.  switch ($type) {
  13.    case "text":
  14.      $value = ($value != "") ? "'" . $value . "'" : "NULL";
  15.      break;
  16.    case "int":
  17.      $value = ($value != "") ? intval($value) : "NULL";
  18.      break;
  19.    case "double":
  20.      $value = ($value != "") ? "'" . doubleval($value) . "'" : "NULL";
  21.      break;
  22.    case "date":
  23.      $value = ($value != "") ? "'" . $value . "'" : "NULL";
  24.      break;
  25.  }
  26.  return $value;
  27. }
  28. ?>

insert-demo1.php

Código
  1. <?php
  2. require("conexion.php");
  3. // insertarmos el registro
  4. mysql_query("INSERT INTO producto (codigo, nombre, nota) VALUES ('Apple', '1 Infinite Loop, Cupertino', 899610)");
  5. // obtenemos el ID del registro
  6. ?>


insert-demo2.php

Código
  1. <?php
  2. require("conexion.php");
  3. $status = "";
  4. if (isset($_POST["codigo"])) {
  5. $codigo = $_POST["codigo"];
  6. $nombre = $_POST["nombre"];
  7. $nota = $_POST["nota"];
  8.  
  9. $sql = "INSERT INTO producto (codigo, nombre, nota) ";
  10.    $sql.= "VALUES ('".$codigo."', '".$nombre."', '".$nota."')";
  11.  
  12. mysql_query($sql, $conexion);
  13. $status = "ok";
  14. }
  15. ?>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  20. <title>PHP con MySQL: Insertar datos en MySQL</title>
  21. <link href="styles.css" rel="stylesheet" type="text/css" />
  22. </head>
  23. <body>
  24. <h3>Nueva Empresa</h3>
  25. <?php if ($status == "ok") { ?>
  26. <p class="confirm">Registro guardado correctamente</p>
  27. <?php } ?>
  28. <form method="post" id="frEmpresa" action="insert-demo2.php">
  29. <label for="nombre">Nombre</label>
  30.    <input type="text" id="nombre" name="nombre" />
  31.    <br />
  32.    <label for="direccion">Direcci&oacute;n</label>
  33.    <input type="text" id="direccion" name="direccion" />
  34.    <br />
  35.    <label for="telefono">Telefono</label>
  36.    <input type="text" id="telefono" name="telefono" />
  37.    <br />
  38.    <label for="bts">&nbsp;</label>
  39.    <button type="submit">Guardar</button>
  40.    <button type="reset">Limpiar</button>
  41. </form>
  42. </body>
  43. </html>


insert-demo3.php

Código
  1. <?php
  2. require("conexion.php");
  3. require("funciones.php");
  4. $status = "";
  5.  
  6. if (isset($_POST["codigo"])) {
  7. $nombre = sqlValue($_POST["codigo"], "text");
  8. $direccion = sqlValue($_POST["nombre"], "text");
  9. $telefono = sqlValue($_POST["nota"], "text");
  10.  
  11. $sql = "INSERT INTO producto (codigo, nombre, nota) ";
  12.    $sql.= "VALUES ('".$codigo."', '".$nombre."', '".$nota."')";
  13.  
  14. echo $sql;
  15.  
  16. mysql_query($sql, $conexion);
  17. $status = "ok";
  18. }
  19. ?>
  20. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  21. <html xmlns="http://www.w3.org/1999/xhtml">
  22. <head>
  23. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  24. <title>PHP con MySQL: Insertar datos en MySQL</title>
  25. <link href="styles.css" rel="stylesheet" type="text/css" />
  26. </head>
  27. <body>
  28. <h3>Nueva Empresa</h3>
  29. <?php if ($status == "ok") { ?>
  30. <p class="confirm">Registro guardado correctamente</p>
  31. <?php } ?>
  32. <form method="post" id="frEmpresa" action="insert-demo3.php">
  33. <label for="nombre">Nombre</label>
  34.    <input type="text" id="nombre" name="nombre" />
  35.    <br />
  36.    <label for="direccion">Direcci&oacute;n</label>
  37.    <input type="text" id="direccion" name="direccion" />
  38.    <br />
  39.    <label for="telefono">Telefono</label>
  40.    <input type="text" id="telefono" name="telefono" />
  41.    <br />
  42.    <label for="bts">&nbsp;</label>
  43.    <button type="submit">Guardar</button>
  44.    <button type="reset">Limpiar</button>
  45. </form>
  46. </body>
  47. </html>


lo acomode asi no le ingrese mas campos solo esos 3 para probar pero nada todavia sigue sin ingresar campos
42  Programación / PHP / Re: problemas al ingresar datos con php en: 17 Julio 2014, 20:57 pm
sas hay estoy en 0, no tendras un ejemplo por hay no tan complicado que me pases por fa
43  Programación / PHP / problemas al ingresar datos con php en: 17 Julio 2014, 20:21 pm
hola buenas tardes estoy tratando de ingresar unos datos a mi base de datos la cual lleva como nombre carrito

tiene carrito producto y usuarios

con los campos

id nombre codigo nota valor estado

entonces tengo esto

conexion.php

Código
  1. <?php
  2. $conexion = mysql_connect("localhost", "root", "") or trigger_error(mysql_error(),E_USER_ERROR);
  3. mysql_select_db("carrito", $conexion);
  4. ?>

insert1.php

Código
  1. <?php
  2. require("conexion.php");
  3. // insertarmos el registro
  4. mysql_query("INSERT INTO carrito (codigo, nombre, nota, valor, estado) VALUES ('Apple', '1 Infinite Loop, Cupertino', 899610)");
  5. // obtenemos el ID del registro
  6. ?>

insert2.php

Código
  1. <?php
  2. require("conexion.php");
  3. require("funciones.php");
  4. $status = "";
  5.  
  6. if (isset($_POST["codigo"])) {
  7. $nombre = sqlValue($_POST["codigo"], "text");
  8. $direccion = sqlValue($_POST["nombre"], "text");
  9. $telefono = sqlValue($_POST["nota"], "text");
  10. $direccion = sqlValue($_POST["valor"], "text");
  11. $direccion = sqlValue($_POST["estado"], "text");
  12.  
  13. $sql = "INSERT INTO producto (codigo, nombre, nota, valor, estado) ";
  14.    $sql.= "VALUES ('".$codigo."', '".$nombre."', '".$nota.", '".$valor.", '".$estado."')";
  15.  
  16. echo $sql;
  17.  
  18. mysql_query($sql, $conexion);
  19. $status = "ok";
  20. }
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23. <html xmlns="http://www.w3.org/1999/xhtml">
  24. <head>
  25. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  26. <title>PHP con MySQL: Insertar datos en MySQL</title>
  27. <link href="styles.css" rel="stylesheet" type="text/css" />
  28. </head>
  29. <body>
  30. <h3>Nueva Empresa</h3>
  31. <?php if ($status == "ok") { ?>
  32. <p class="confirm">Registro guardado correctamente</p>
  33. <?php } ?>
  34. <form method="post" id="frEmpresa" action="insert-demo2.php">
  35. <label for="nombre">codigo</label>
  36.    <input type="text" id="nombre" name="nombre" />
  37.    <br />
  38.    <label for="direccion">nombre</label>
  39.    <input type="text" id="direccion" name="direccion" />
  40.    <br />
  41.    <label for="telefono">nota</label>
  42.    <input type="text" id="telefono" name="telefono" />
  43.    <br />
  44.    <label for="telefono">valor</label>
  45.    <input type="text" id="telefono" name="telefono" />
  46.    <br />
  47.    <label for="telefono">estado</label>
  48.    <input type="text" id="telefono" name="telefono" />
  49.    <br />
  50.    <label for="bts">&nbsp;</label>
  51.    <button type="submit">Guardar</button>
  52.    <button type="reset">Limpiar</button>
  53. </form>
  54. </body>
  55. </html>

funciones.php

Código
  1. <?php
  2. function getParam($param, $default) {
  3. $result = $default;
  4. if (isset($param)) {
  5.   $result = (get_magic_quotes_gpc()) ? $param : addslashes($param);
  6. }
  7. return $result;
  8. }
  9. function sqlValue($value, $type) {
  10.  $value = get_magic_quotes_gpc() ? stripslashes($value) : $value;
  11.  $value = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($value) : mysql_escape_string($value);
  12.  switch ($type) {
  13.    case "text":
  14.      $value = ($value != "") ? "'" . $value . "'" : "NULL";
  15.      break;
  16.    case "int":
  17.      $value = ($value != "") ? intval($value) : "NULL";
  18.      break;
  19.    case "double":
  20.      $value = ($value != "") ? "'" . doubleval($value) . "'" : "NULL";
  21.      break;
  22.    case "date":
  23.      $value = ($value != "") ? "'" . $value . "'" : "NULL";
  24.      break;
  25.  }
  26.  return $value;
  27. }
  28. ?>

no me da error en ningun lado pero cuando le doy agregar pareciera que los agrega y limpia el formulario pero nada que ver no ingresa los datos
44  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 22:05 pm
sas no me aconstumbro al session start minus muchas gracias me has salvado la patria bueno mi codigo esta disponible para todo aquel que lo necesite

y Gracias al Compañero MinusFour por toda la paciencia que me tubo eres un crack mi hermano si no fuera por ti no hubiera terminado esta parte del proyecto mi pana eres el mejor
45  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 21:57 pm
ME ESTA DANDO ESTE ERROR

Notice: Undefined variable: _SESSION in C:\xampp\htdocs\1carrito\mis_pedidos.php on line 100

Código
  1. <?php
  2. include_once("php_conexion.php");
  3. if(!empty($_GET['del'])){
  4. $id=$_GET['del'];
  5. mysql_query("DELETE FROM carrito WHERE codigo='$id'");
  6. header('location:mis_pedidos.php');
  7.  
  8. }
  9. //-------------------------------------------------------------------
  10. ?>
  11. <!DOCTYPE html>
  12. <html lang="es">
  13.  <head>
  14.    <meta charset="utf-8">
  15.    <title>Carrito de Compras</title>
  16.    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  17.    <meta name="description" content="">
  18.    <meta name="author" content="">
  19.  
  20.    <!-- Le styles -->
  21.    <link href="css/bootstrap.css" rel="stylesheet">
  22.    <style type="text/css">
  23.      body {
  24.        padding-top: 60px;
  25.        padding-bottom: 40px;
  26.      }
  27.    </style>
  28.    <link href="css/bootstrap-responsive.css" rel="stylesheet">
  29.  
  30.    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  31.    <!--[if lt IE 9]>
  32.      <script src="../assets/js/html5shiv.js"></script>
  33.    <![endif]-->
  34.  
  35.    <!-- Fav and touch icons -->
  36.  
  37.    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
  38.    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
  39.      <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
  40.                    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
  41.                                   <link rel="shortcut icon" href="ico/favicon.png">
  42.  </head>
  43.  
  44.  <body>
  45.  
  46.    <div class="navbar navbar-inverse navbar-fixed-top">
  47.      <div class="navbar-inner">
  48.        <div class="container">
  49.          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  50.            <span class="icon-bar"></span>
  51.            <span class="icon-bar"></span>
  52.            <span class="icon-bar"></span>
  53.          </button>
  54.          <a class="brand" href="#">Tienda Venezuela Computer</a>
  55.          <div class="nav-collapse collapse">
  56.            <ul class="nav">
  57.              <li><a href="index.php">Principal</a></li>
  58.              <li class="active"><a href="mis_pedidos.php">Mis Pedidos</a></li>
  59.            </ul>
  60.          </div><!--/.nav-collapse -->
  61.        </div>
  62.      </div>
  63.    </div>
  64.  
  65.    <div class="container">
  66.  
  67.      <!-- Main hero unit for a primary marketing message or call to action -->
  68.      <div class="hero-unit" align="center">
  69.         <img src="file:///C|/Users/Secretaria/Desktop/Nueva carpeta/images/slogan-bg.jpg" class="img-polaroid">
  70.      </div>
  71.  
  72.      <!-- Example row of columns -->
  73.      <div class="row">
  74.  
  75.      </div>
  76.      <div align="center">
  77.       <?php
  78. if(!empty($_POST['n_cant'])){
  79. $n_cant=$_POST['n_cant'];
  80. $n_codigo=$_POST['codigo'];
  81. $oProducto=new Consultar_Producto($n_codigo);
  82. mysql_query("UPDATE carrito SET cantidad='$n_cant' WHERE codigo='$n_codigo'");
  83.  
  84. echo '<div class="alert alert-success" align="center">
  85.  <button type="button" class="close" data-dismiss="alert">×</button>
  86.  <strong>Cantidad del Producto "'.$oProducto->consultar('nombre').'" Actualizada con Exito</strong>
  87. </div>';
  88. }
  89. ?>
  90.       <table class="table table-bordered">
  91.          <tr class="info">
  92.            <td><strong class="text-info">Articulo</strong></td>
  93.            <td><div align="right"><strong class="text-info">Valor Unitario</strong></div></td>
  94.            <td><center><strong class="text-info">Cantidad</strong></center></td>
  95.            <td><div align="right"><strong class="text-info">Total</strong></div></td>
  96.            <td></td>
  97.          </tr>
  98.          <?php
  99.   $total=0;$neto=0;
  100.   $pa=mysql_query("SELECT * FROM carrito WHERE usu = '". $_SESSION["username"] ."'");
  101.            while($row=mysql_fetch_array($pa)){
  102. $oProducto=new Consultar_Producto($row['codigo']);
  103. $total=$row['cantidad']*$oProducto->consultar('valor');#cantidad * valor unitario
  104. $neto=$neto+$total;#acumulamos el neto
  105.  ?>
  106.          <tr>
  107.            <td>
  108.             <div align="center">
  109.                     <strong><?php echo $oProducto->consultar('nombre'); ?></strong><br>
  110.                     <img src="img/producto/<?php echo $row['codigo']; ?>.jpg" width="200" height="200" class="img-polaroid">
  111.                </div>
  112.            </td>
  113.            <td><br><br><div align="right">$ <?php echo number_format($oProducto->consultar('valor'),2,",","."); ?></div></td>
  114.            <td><br><br>
  115.             <center>
  116.                 <a href="#cant<?php echo $row['codigo']; ?>" role="button" class="btn" data-toggle="modal" title="Editar Cantidad">
  117. <span class="badge badge-success"><?php echo $row['cantidad']; ?></span>
  118.                    </a>
  119.                </center>
  120.            </td>
  121.            <td><br><br><div align="right">$ <?php echo number_format($total,2,",","."); ?></div></td>
  122.            <td><br><br>
  123.            <center>
  124.             <a href="mis_pedidos.php?del=<?php echo $row['codigo']; ?>" class="btn btn-mini" title="Eliminar de la Lista">
  125.                 <i class="icon-remove"></i>
  126.                </a>
  127.                </center>
  128.            </td>
  129.          </tr>
  130.  
  131.        <div id="cant<?php echo $row['codigo']; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  132.       <form name="form<?php $row['codigo']; ?>" method="post" action="">
  133.           <input type="hidden" name="codigo" value="<?php echo $row['codigo']; ?>">
  134.            <div class="modal-header">
  135.            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  136.            <h3 id="myModalLabel">Actualizar Existencia</h3>
  137.            </div>
  138.            <div class="modal-body">
  139.              <div class="row-fluid">
  140.                <div class="span6">
  141.                     <img src="img/producto/<?php echo $row['codigo']; ?>.jpg" width="200" height="200" class="img-polaroid">
  142.                    </div>
  143.                <div class="span6">
  144.                     <strong><?php echo $oProducto->consultar('nombre'); ?></strong><br>
  145.                <strong>Cantidad Actual: </strong><?php echo $row['cantidad']; ?><br><br>
  146.                        <strong>Nueva Cantidad</strong><br>
  147.                        <input name="n_cant" value="<?php echo $row['cantidad']; ?>" type="number" autocomplete="off" min="1">
  148.                    </div>
  149.                </div>
  150.            </div>
  151.            <div class="modal-footer">
  152.            <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i> <strong>Cerrar</strong></button>
  153.             <button type="submit" class="btn btn-primary"><i class="icon-ok"></i> <strong>Actualizar</strong></button>
  154.            </div>
  155.            </form>
  156.        </div>
  157.  
  158.          <?php } ?>
  159.          <tr class="info">
  160.            <td>&nbsp;</td>
  161.            <td>&nbsp;</td>
  162.            <td><div align="right"><strong>NETO A PAGAR</strong></div></td>
  163.            <td><div align="right"><strong>$ <?php echo number_format($neto,2,",","."); ?></strong></div></td>
  164.            <td>&nbsp;</td>
  165.          </tr>
  166.        </table>
  167.       <p>
  168. <form method="POST" action="registra.php">  
  169.  
  170.    <p>&nbsp;</p>  
  171.  
  172. </form>
  173.  
  174.      </div>
  175.  
  176.      <hr>
  177.  
  178.      <footer>
  179.        <p>&copy; Venezuela Computer 2014</p>
  180.      </footer>
  181.  
  182.    </div> <!-- /container -->
  183.  
  184.    <!-- Le javascript
  185.    ================================================== -->
  186.    <!-- Placed at the end of the document so the pages load faster -->
  187.    <script src="js/jquery.js"></script>
  188.    <script src="js/bootstrap-transition.js"></script>
  189.    <script src="js/bootstrap-alert.js"></script>
  190.    <script src="js/bootstrap-modal.js"></script>
  191.    <script src="js/bootstrap-dropdown.js"></script>
  192.    <script src="js/bootstrap-scrollspy.js"></script>
  193.    <script src="js/bootstrap-tab.js"></script>
  194.    <script src="js/bootstrap-tooltip.js"></script>
  195.    <script src="js/bootstrap-popover.js"></script>
  196.    <script src="js/bootstrap-button.js"></script>
  197.    <script src="js/bootstrap-collapse.js"></script>
  198.    <script src="js/bootstrap-carousel.js"></script>
  199.    <script src="js/bootstrap-typeahead.js"></script>
  200.    <script>
  201. $(function() {
  202.            var offset = $("#sidebar").offset();
  203.            var topPadding = 15;
  204.            $(window).scroll(function() {
  205.                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 */
  206.                    $("#sidebar").stop().animate({
  207.                        marginTop: $(window).scrollTop() - offset.top + topPadding
  208.                    });
  209.                } else {
  210.                    $("#sidebar").stop().animate({
  211.                        marginTop: 0
  212.                    });
  213.                };
  214.            });
  215.        });
  216. </script>
  217.  
  218.  </body>
  219. </html>
  220.  
46  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 21:38 pm
jajajaja aora en la parte de mis pedidos aparecen los pedidos de los 2 usuarios en mis_pedidod.php

y coloque

mysql_query("SELECT * FROM carrito WHERE usu = '". $_SESSION["username"] ."'");

y me da error de variable o_O
47  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 21:23 pm
listoooooooooooooooooooooooooooooooooo

bueno quien quiera el codigo de la tienda yo se lo paso :-D

aora el problema es este minus

entro con otro usuario y queda el mismo pedido del usuario anterior
48  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 21:17 pm
esta mal el query pero en donde porque todo lo deje igual

sigue dando el mismo error con el query que me pasastes

es decir puedo darle varias veces y el producto lo agrega pero no seguido hay que darle 10 veces click para que lo agregue y para agregar el otro se pone dificil tambien
49  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 20:30 pm
minus ya esta listo ya consegui que mostrara el nombre del usuario que compro :-D jajaja probando algo loco y me salio....

aora mi otra pregunta es que solo me agrega un solo producto del carrito :-( te muestro como quedo el codigo

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

que hice en vez de hacerlo con el campo ced como me habias comentado lo hice con el campo usu :-D y solo agregue una linea en la base de datos carrito que diga usu

lo que cambie fue esta parte como te podras dar cuenta

Código
  1. <?php
  2. if(!empty($_POST['codigo'])){
  3. $codigo=$_POST['codigo'];
  4. $pa=mysql_query("SELECT codigo, cantidad FROM carrito WHERE usu = '" . $_SESSION["username"] . "'");
  5. if($row=mysql_fetch_array($pa)){
  6. $cantidad=$row['cantidad']+1;
  7. mysql_query("UPDATE carrito SET cantidad =  '" . $cantidad . "' WHERE usu = '" . $_SESSION["username"] . "' AND codigo =  '" . $codigo . "'");
  8. }else{
  9. mysql_query("INSERT INTO carrito (codigo, cantidad, usu) VALUES('" . $codigo . "', '1', '" . $_SESSION["username"] . "')");
  10. }
  11. }
  12. ?>

solo me agrega al que yo le de agregar carrito primero

si le doy a producto 1, cuando le quiero dar a producto 2 no me lo agarra solo me permite seguir agregando a producto 1
50  Programación / PHP / Re: Duda sobre guardar datos en cada usuario en php en: 16 Julio 2014, 19:41 pm
no agrega nada solo coloca en el campo ced el numero 0
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines