Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/08/2011, 23:18
kushanku
 
Fecha de Ingreso: noviembre-2008
Mensajes: 28
Antigüedad: 15 años, 5 meses
Puntos: 0
listado de productos

Hola a todos y muchas gracias de ante mano espero que me puedan ayudar tengo un inconveniente con un carro de compras. Que consta de un listado de categorias donde se selecciona la categoria y despliega los productos de dicha categoria hasta ahi todo funciona correctamente. Mi problema comienza cuando los voy agregar al carrito, no envia ningun producto a la pagina ver_carro, como podira hacer para agregar los productos al carro?. A continuacion posteo mi codigo y espero que me puedan ayudar y muchas gracias a todos nuevamente.

listado_categoria.php
===============================

<?php
include("conector.php");
$sql = "select * from categoria";
$result = mysql_query($sql, $conexion) or die (mysql_error());
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LESICOS</title>
</head>

<body>
<table border="1" align="center" width="200" cellpadding="2" cellspacing="2">
<tr align="center">
<td>Categoria</td>
</tr>
<?php if(mysql_num_rows($result) > 0)
{
while($fila = mysql_fetch_assoc($result))
{
?>
<tr align="center">
<td><a href="?pagina=listado_producto&id_categoria=<?php echo $fila["id_categoria"];?>"><?php echo $fila["categoria"];?></a></td>
</tr>
<?php
}//fin del while
}//fin del if
else{
echo "No se encontraron registros para mostrar";
}//fin del else
?>
</table>
<?php mysql_free_result($result);?>
</body>
</html>


Listado_productos.php
=================================

<?php
include("conector.php");
$sql = "select * from producto where id_categoria = '".$_GET['id_categoria']."'";
$result = mysql_query($sql, $conexion) or die (mysql_error());
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LESICOS</title>
</head>

<body>
<form method="post" action="agregar.php">
<table border="1" align="center" width="300" cellpadding="2" cellspacing="2">
<tr align="center">
<td>Producto</td>
<td>Precio</td>
<td>Cantidad</td>
<td><a href="agregar.php?id_prod=<?php $fila["id_prod"];?>"><img src="img/agregar.png" height="32" width="32" border="0"></a></td>
</tr>
<?php if(mysql_num_rows($result) > 0)
{
while($fila = mysql_fetch_assoc($result))
{
?>
<tr align="center">
<td><?php echo $fila["nom_prod"];?></td>
<td><?php echo $fila["precio"];?></td>
<td>
<select name="cantidad[<?php echo $fila["id_prod"];?>]">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</td>
<td><input type="checkbox" name="seleccion" value="<?php echo $fila["id_prod"];?>"></td>
</tr>
<?php
}//fin del while
}//fin del if
else{
echo "No se encontraron datos para mostrar";
}//fin del else
?>
</table>
</form>
<?php
mysql_free_result($result);
?>
</body>
</html>

agregar.php
===========================

<?php
session_start();
$id_prod=$_POST['id_prod'];
$cantidad=$_POST['cantidad'];
$seleccion=$_POST['seleccion'];
$carro[$id_prod] = array(
"codigo" => $_POST['id_prod'],
"nom_prod" => $_POST['nom_prod'],
"cantidad" => $_POST['cantidad'],
"precio" => $_POST['precio'],
"seleccion" => $_POST['seleccion'],
);
$_SESSION['carro']=$carro;
header("Location:agregar_carrito.php");
?>