Tema: Checkbox
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/06/2013, 08:26
D2DVD
 
Fecha de Ingreso: diciembre-2008
Ubicación: Madrid
Mensajes: 6
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Checkbox

Jo muchas gracias de antemano por tu rapidez. Sino te importa te mando el codigo del carro es este:
<?php require_once('Connections/sumar.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_sumar, $sumar);
$query_Recordset1 = "SELECT * FROM `berriz`";
$Recordset1 = mysql_query($query_Recordset1, $sumar) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$query_Recordset1 = "SELECT * FROM berriz";
$Recordset1 = mysql_query($query_Recordset1, $sumar) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
session_start();
if(isset($_SESSION['carrito']) || isset($_POST['strNombre'])){
if(isset($_SESSION['carrito'])){
$carrito_mio=$_SESSION['carrito'];
if(isset($_POST['strNombre'])){
$strNombre=$_POST['strNombre'];
$dblPrecio=$_POST['dblPrecio'];
$cantidad=$_POST['cantidad'];
$donde=-1;
for($i=0;$i<=count($carrito_mio)-1;$i ++){
if($strNombre==$carrito_mio[$i]['strNombre']){
$donde=$i;
}
}
if($donde != -1){
$cuanto=$carrito_mio[$donde]['cantidad'] + $cantidad;
$carrito_mio[$donde]=array("strNombre"=>$strNombre,"dblPrecio"=>$dblPr ecio,"cantidad"=>$cuanto);
}else{
$carrito_mio[]=array("strNombre"=>$strNombre,"dblPrecio"=>$dblPr ecio,"cantidad"=>$cantidad);
}
}
}else{
$strNombre=$_POST['strNombre'];
$dblPrecio=$_POST['dblPrecio'];
$cantidad=$_POST['cantidad'];
$carrito_mio[]=array("strNombre"=>$strNombre,"dblPrecio"=>$dblPr ecio,"cantidad"=>$cantidad);
}
if(isset($_POST['cantidad2'])){
$id=$_POST['id'];
$cuantos=$_POST['cantidad2'];
if($cuantos<1){
$carrito_mio[$id]=NULL;
}else{
}
$carrito_mio[$id]['cantidad']=$cuantos;
}
if(isset($_POST['id2'])){
$id=$_POST['id2'];
$carrito_mio[$id]=NULL;
}
$_SESSION['carrito']=$carrito_mio;
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Y sigue asi:

<table width="96%" border="0" align="center">
<tr>
<td width="49%" height="18" align="center" style="font-weight: bold">Nombre del producto</td>
<td width="11%" align="center" style="font-weight: bold">Precio</td>
<td width="18%" align="center" style="font-weight: bold">Cantidad</td>
<td width="14%" align="center" style="font-weight: bold">&nbsp;</td>
<td width="8%" align="center"><strong>Eliminar</strong></td>
</tr><?php
if(isset($_SESSION['carrito'])){
$total=0;
for($i=0;$i<=count($carrito_mio)-1;$i ++){
if($carrito_mio[$i]!=NULL){

?>
<tr bgcolor=>
<td height="18" align="center" valign="middle" nowrap><?php print $carrito_mio[$i]['strNombre']; ?> </td>
<td height="22" align="center" valign="middle"><?php print $carrito_mio[$i]['dblPrecio']; ?></td>
<td height="22" align="right" valign= middle>
<form id="form1" name="form1" method="post" action="">
<label for="cantidad2"></label>
<input name="cantidad2" type="text" id="cantidad2" value="<?php print $carrito_mio[$i]['cantidad']; ?>" size="1" />
<input name="id" type="hidden" id="id" value="<?php print $i; ?>" />
<input name="imageField" type="image" id="imageField" src="img/ACTUALIZ.GIF" alt="actualizar" />
</form></td>
<td height="22" align="right" valign="middle"> <?php print $carrito_mio[$i]['dblPrecio'] * $carrito_mio[$i]['cantidad']; ?> €</td>
<td height="22" align="center" valign="top"><form id="form2" name="form2" method="post" action="">
<input name="id2" type="hidden" id="id2" value="<?php print $i; ?>" />
<input name="imageField2" type="image" id="imageField2" src="img/ico_papelera-2.gif" alt="eliminar" />
</form></td>
</tr>
<?php
$total=$total + ($carrito_mio[$i]['dblPrecio'] * $carrito_mio[$i]['cantidad']);
}
}
}
?>
<tr>

<td height="18">
</td>
<td height="18">&nbsp;</td>
<td height="18" align="right" class="bold">&nbsp;</td>
<td height="18" align="right">&nbsp;</td>
<td height="18" align="center">&nbsp;</td>
</tr>
<tr>
<td height="18" nowrap>&nbsp;</td>
<td height="18">&nbsp;</td>
<td height="18" align="right" class="bold">&nbsp;</td>
<td height="18" align="right">&nbsp;</td>
<td height="18" align="center">&nbsp;</td>
</tr>
<tr>
<td height="18" nowrap>&nbsp;</td>
<td>&nbsp;</td>
<td height="18" align="right" class="bold"><span class="letras_bold"><strong>Total :</strong></span></td>
<td height="18" align="right"><strong><?php print $total; ?> €</strong></td>
<td height="18" align="center">&nbsp;</td>
</tr>
<tr>
<td height="18" colspan="5" align="right" nowrap><form id="form3" name="form3" method="post" action="sumario_sin_iva.php">
<input type="submit" name="button" id="button" value="Comprar" />
</form> </td>
</tr>
</table>

Muchas Gracias por tu interes.