-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcuenta.php
More file actions
76 lines (72 loc) · 2.73 KB
/
Copy pathcuenta.php
File metadata and controls
76 lines (72 loc) · 2.73 KB
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
<!DOCTYPE html>
<html>
<head>
<?php include "./layouts/head.php" ?>
</head>
<body>
<?php include "./layouts/header.php" ?>
<?php
$conexion = new mysqli("localhost", "root", "", "vicionow");
if ($conexion->connect_error) {
die('Error de conexión: ' . $conexion->connect_error);
}
if (!sesion_activa()) {
header('Location: login.php');
exit();
}
?>
<div class="container mt-5">
<h1>Mis Compras</h1>
<br>
<div class="row">
<div class="card mb-3">
<table class="table" style="text-align: center;">
<thead>
<tr>
<th>Fecha</th>
<th>Producto</th>
<th>Cantidad</th>
<th>Precio</th>
<th>Código</th>
</tr>
</thead>
<tbody>
<?php
$stmt = $conexion->prepare("SELECT *
FROM compras
INNER JOIN juegos ON juegos.ID_Juego = compras.ID_Juego
WHERE compras.ID_Usuario = ? ORDER BY compras.Fecha_Compra ASC");
$stmt->bind_param("s", $_SESSION["usuario_id"]);
$stmt->execute();
$result = $stmt->get_result();
$existencias = $conexion->prepare("SELECT * FROM compras WHERE ID_Usuario = ?");
$existencias->bind_param("s", $_SESSION["usuario_id"]);
$existencias->execute();
$existencias->store_result();
if ($existencias->num_rows > 0) {
while ($row = $result->fetch_assoc())
{
?>
<tr>
<td><?php echo htmlspecialchars($row['Fecha_Compra']); ?></td>
<td><?php echo htmlspecialchars($row['Nombre']); ?></td>
<td><?php echo htmlspecialchars($row['Cantidad']); ?></td>
<td><?php echo htmlspecialchars($row['Precio']); ?> €</td>
<td><?php echo htmlspecialchars($row['Codigo_Descarga']); ?></td>
</tr>
<?php }
} else
{
echo "<tr><td></td>";
echo "<td></td>";
echo "<td>No tienes ninguna compra</td>";
echo "<td></td>";
echo "<td></td></tr>";
}?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>