Carrito de compras
Publicado por Raul gomez (6 intervenciones) el 14/05/2020 17:48:28
Buenos días, estoy realizando un carrito de compras, pero al correr el codigo me marca error en la linea 29 y la verdad no se que este mal en el codigo.
Este es el error que manda: Parse error: syntax error, unexpected ''modelo'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\xampp\htdocs\flamestore\flamestore\flamecarrito\carritodecompras.php on line 29
Espero y me ayuden por favor. Que tengan buen día.
Y este es el codigo del carrito:
Este es el error que manda: Parse error: syntax error, unexpected ''modelo'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\xampp\htdocs\flamestore\flamestore\flamecarrito\carritodecompras.php on line 29
Espero y me ayuden por favor. Que tengan buen día.
Y este es el codigo del carrito:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
php
session_start();
include 'conexion.php';
if(isset($_SESSION['carrito'])){
if (isset($_GET['id_tenis'])){
$arreglo=$_SESSION['carrito'];
$encontro=false;
$numero=0;
for($i=0;$i<count($arreglo);$i++){
if ($arreglo[$i]['Id_tenis']==$_GET['id_tenis']) {
$encontro=true;
$numero=$i;
}
}
if ($encontro==true) {
$arreglo[$numero]['Cantidad']=$arreglo[$numero]['Cantidad']+1;
$_SESSION['carrito']=$arreglo;
}else{
$modelo="";
$precio=0;
$imagen="";
$re=mysqli_query($con,"SELECT * FROM tenis WHERE id_tenis=".$_GET['id_tenis']);
while($f=mysqli_fetch_array($re)){
$modelo=$f['modelo'];
$precio=$f['precio'];
$imagen=$f['imagen'];
}
$datosNuevos=array('Id_tenis'=>$_GET['id_tenis']
'modelo'=>$modelo,
'precio'=>$precio,
'imagen'=>$imagen,
'Cantidad'=>1);
array_push($arreglo, $datosNuevos);
$_SESSION['carrito']=$arreglo;
}
}
}else{
if(isset($_GET['id_tenis'])){
$modelo="";
$precio=0;
$imagen="";
$re=mysqli_query($con"SELECT * FROM tenis WHERE id_tenis=".$_GET['id_tenis']);
while($f=mysqli_fetch_array($re)){
$modelo=$f['modelo'];
$precio=$f['precio'];
$imagen=$f['imagen'];
}
$arreglo[]=array('Id_tenis'=>$_GET['id_tenis']
'Modelo'=>$modelo,
'Precio'=>$precio,
'Imagen'=>$imagen,
'Cantidad'=>1);
}
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="">
<script type="text/javascript" src="js/scripts.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<header>
<h1>CARRITO DE COMPRAS</h1>
<a href="carritodecompras.php" title="VER CARRITO DE COMPRAS"><img src="./imagenes/carrito.png"></a>
</header>
<section>
<?php
$total=0;
if (isset($_SESSION['carrito'])) {
$datos=$_SESSION['carrito'];
$total=0;
for($i=0;$i<count($datos);$i++){
?>
<div class="producto">
<center>
<img src="productosimg/<?php echo $datos[$i]['Imagen']; ?>" width="20">
<span><?php echo $datos[$i]['Modelo'] ?></span><br>
<span>Precio: <?php echo $datos[$i]['Precio'] ?></span><br>
<span>Cantidad<input type="text" value="<?php echo $datos[$i]['Cantidad']; ?>" data-precio="<?php echo $datos[$i]['Precio'] ?>"data_id="<?php echo $datos [$i]['Id_tenis'];?>" id_tenis="cantidad"></span><br>
<span class="subtotal">Subtotal: <?php echo $datos[$i]['Cantidad']*$datos; ?></span>
</center>
</div>
<?php
$total=($datos[$i]['Cantidad']*$datos[$i]['Precio'])+$total;
}
}else{
echo '<center><h2>EL CARRITO ESTA VACIO</h2></center>';
}
echo '<center><h2 id="total">TOTAL: '.$total.'</h2></center>';
?>
<center><a href="./">VER PRODUCTOS</a></center>
</section>
</body>
</html>
Valora esta pregunta
0