Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/01/2015, 15:54
eslomao
 
Fecha de Ingreso: noviembre-2014
Mensajes: 60
Antigüedad: 9 años, 6 meses
Puntos: 0
mismo producto en distitnas lineas

hola chicos, aqui ando de nuevo, por fin consegui ir sumando los productos, mi problena es que si sumo dos productos iguales me los va sacando en una linea distinta, en vez de en la misma linea, intente con un whilw, pero no me deja hacerlo, pues ya tengo hecho uno y dreamweaver me lo prohibe, quizas haya otra manera, os pego el codigo a ver que tal,

Código PHP:
Ver original
  1. <?php require_once('Connections/conexionzapatos.php'); ?>
  2. <?php require_once('Connections/conexionzapatos.php'); ?>
  3. <?php
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7.   if (PHP_VERSION < 6) {
  8.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9.   }
  10.  
  11.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  12.  
  13.   switch ($theType) {
  14.     case "text":
  15.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  16.       break;    
  17.     case "long":
  18.     case "int":
  19.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  20.       break;
  21.     case "double":
  22.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  23.       break;
  24.     case "date":
  25.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  26.       break;
  27.     case "defined":
  28.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  29.       break;
  30.   }
  31.   return $theValue;
  32. }
  33. }
  34.  
  35. $editFormAction = $_SERVER['PHP_SELF'];
  36. if (isset($_SERVER['QUERY_STRING'])) {
  37.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  38. }
  39.  
  40. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  41.   $insertSQL = sprintf("INSERT INTO tblcompra (idCompra, idUsuario, fchFecha, intTipoPago, dblTotal, intEstado, strNombre) VALUES (%s, %s, %s, %s, %s, %s, %s)",
  42.                        GetSQLValueString($_POST['idCompra'], "int"),
  43.                        GetSQLValueString($_POST['idUsuario'], "int"),
  44.                        GetSQLValueString($_POST['fchFecha'], "date"),
  45.                        GetSQLValueString($_POST['intTipoPago'], "text"),
  46.                        GetSQLValueString($_POST['dblTotal'], "double"),
  47.                        GetSQLValueString($_POST['intEstado'], "int"),
  48.                        GetSQLValueString($_POST['strNombre'], "text"));
  49.  
  50.   mysql_select_db($database_conexionzapatos, $conexionzapatos);
  51.   $Result1 = mysql_query($insertSQL, $conexionzapatos) or die(mysql_error());
  52.  
  53.   $insertGoTo = "prueb1234.php";
  54.   if (isset($_SERVER['QUERY_STRING'])) {
  55.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  56.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  57.   }
  58.   header(sprintf("Location: %s", $insertGoTo));
  59. }
  60.  
  61. $varUsuario_Datos = "0";
  62. if (isset($_SESSION["MM_IdUsuario"])) {
  63.   $varUsuario_Datos = $_SESSION["MM_IdUsuario"];
  64. }
  65. mysql_select_db($database_conexionzapatos, $conexionzapatos);
  66. $query_Datos = sprintf("SELECT * FROM tblcarrito WHERE tblcarrito.idUsuario = %s AND tblcarrito.intTransaccionEfectuada = 0", GetSQLValueString($varUsuario_Datos, "int"));
  67. $Datos = mysql_query($query_Datos, $conexionzapatos) or die(mysql_error());
  68. $row_Datos = mysql_fetch_assoc($Datos);
  69. $totalRows_Datos = mysql_num_rows($Datos);
  70.  
  71. $hoy = date("Y-m-d");
  72. $Transferencia="Transferencia";
  73. $producto="strNombre";
  74. $contador=0;
  75. $itemsEnCesta=$_SESSION['MM_IdUsuario'];
  76.  
  77. $preciototal = 0;
  78. $multiplicador =  ObtenerIVA()/100;
  79. $valorconIVA = $preciototal * $multiplicador;
  80.  
  81.  
  82. ?>
  83. </script>
  84.     <script type="text/javascript"  href="./js/scripts.js"></script>
  85. <head>
  86. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  87. <!-- InstanceBeginEditable name="doctitle" -->
  88. <title>Documento sin título</title>
  89. <!-- InstanceEndEditable -->
  90. <!-- InstanceBeginEditable name="head" -->
  91. <!-- InstanceEndEditable -->
  92. <link href="estilo/principal.css" rel="stylesheet" type="text/css" />
  93. </head>
  94.  
  95. <body>
  96.  
  97. <div class="container">
  98.   <div class="header"><div class="headerinterior"><img src="images/logotrans.png" width="283" height="64" alt="Tienda Zapatos" /></div></div>
  99.   <div class="subcontenedor">
  100.               <div class="sidebar1">
  101.                <?php include("includes/catalogo.php"); ?>
  102. <!-- end .sidebar1 --></div>
  103.               <div class="content">
  104.                 <h1><!-- InstanceBeginEditable name="Titulo" -->Carrito de la compra<!-- InstanceEndEditable --></h1>
  105.                 <!-- InstanceBeginEditable name="EditRegion4" -->
  106.                
  107.    <td><a href="eliminar_producto.php?recordID=<?php echo $row_Datos['idProducto']; ?>">vaciar</a></td>
  108.       <?php if ($totalRows_Datos > 0) { // Show if recordset not empty ?>
  109. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  110.                   <tr class="ver">
  111.                     <td width="18%">Producto</td>
  112.                     <td width="44%">Unidades</td>
  113.                     <td width="28%">Precio Unidad</td>
  114.                  
  115.                     <td width="10%">Acciones</td>
  116.                   </tr>
  117.                   <?php $preciototal = 0;?>
  118.                   <?php do { ?>
  119.   <tr class="letra">
  120.     <td align=""><?php echo ObtenerNombreProducto($row_Datos['idProducto']); ?></td>
  121.     <td><form name="FComprar" action="carrito_add.php" method="get"><?php echo $row_Datos['intCantidad']; ?>
  122.     <select name="intCantidad" id="intCantidad">  
  123.   <option value="1" selected="selected">1</option><option value="2">2</option><option value="3">3</option>
  124. <option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option>
  125. </select><input name="recordID" type="hidden" value="<?php echo $row_Datos['idProducto']; ?>" /><input name="" type="submit" value="+" />
  126.  
  127.  <select name="intCantidad" id="intCantidad">
  128.    <option value="-1">1</option>
  129.  </select><input name="recordID" type="hidden" value="<?php echo $row_Datos['idProducto']; ?>" /><input name="" type="submit" value="-" />
  130.  
  131.  
  132.  
  133. </form>  
  134.               </td>
  135.     <td ><?php echo ObtenerPrecioProducto($row_Datos['idProducto']); ?> <span class="letra">Euros</span></td>
  136.    
  137.     <td><a href="eliminar_producto.php?recordID=<?php echo $row_Datos['idProducto']; ?>">Eliminar</a></td>
  138.   </tr>
  139. <?php   $preciototal = $preciototal + $row_Datos['intCantidad']* ObtenerPrecioProducto($row_Datos['idProducto']);?>
  140.   <?php } while ($row_Datos = mysql_fetch_assoc($Datos)); ?>
  141.         <tr>
  142.     <td>&nbsp;</td>
  143.     <td align="right">Subtotal:</td>
  144.     <td colspan="2" align="left"> <?php
  145.           $multiplicador =  (100 + ObtenerIVA())/100;
  146.           $valorconIVA = $preciototal * $multiplicador;
  147.           echo $valorconIVA;?>
  148.     </td></tr>
  149.   </table>
  150.            
  151. <br />
  152.              
  153.    <?php } // Show if recordset not empty ?>
  154.    <?php if ($totalRows_Datos == 0) { // Show if recordset empty ?>
  155.   <p>&nbsp;<table width="363" align="center">
  156.     <tr>
  157.       <td width="355" align="center">Su Carro Esta Vacio</td>
  158.       </tr>
  159.   </table>
  160.   <?php } // Show if recordset empty ?>
  161. </p>    
  162.                 <!-- InstanceEndEditable --><!-- end .content --></div>
  163.     <!-- end .subcontenedor -->
  164.     </div>
  165.   <</html>
  166. <?php
  167. ?>