Jump to content

[SOLVED] shoping cart issues


scripterdx

Recommended Posts

i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just replaces the last one. please help!!

 

<!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>my site</title>
<link href="general.css" rel="stylesheet" type="text/css">
<link href="productos.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="funciones.js"></script>
</head>
</head>
<body>
<div id="contenido">
  <?php
include('config.php');
$id=$_GET['i'];



$sql= "SELECT * FROM products WHERE id='$id'";
$consulta = mysql_query($sql);
$row = mysql_fetch_assoc($consulta);

$s=$row['sexo']; 
$c=$row['categoria']; 
$f=$row['fotos'];

$o=$_GET['o'];
$p=$_GET['p'];

?>
  <h1>CARRO DE COMPRAS</h1>
  <table>
    <tr>
      <td width="110">Foto</td>
      <td width="110">Marca</td>
      <td width="110">Producto</td>
      <td width="110">Precio</td>
    </tr>
    <tr>
      <td><img src='thumbs/productos/<?php echo $row['id'];?>_b.jpg'/></td>
      <td class="td"><?php echo $row['marca']; ?></td>
      <td class="td"><?php echo $row['nombre_producto']; ?></td>
      <td class="td"><?php echo $row['precio']; ?></td>
      </tr>
  </table>
</div>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/178486-solved-shoping-cart-issues/
Share on other sites

Your problem is

$row = mysql_fetch_assoc($consulta);

 

You're not looping through the results, meaning your script is always going to show only one row.

 

You should really be doing something like so:

 

while($r = mysql_fetch_assoc($row)){
     echo $r['column_name'];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.