funcionalidad de perfil (estadisticas y nombre)
This commit is contained in:
@@ -85,4 +85,26 @@ switch ($_POST['orden']) {
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
case 'mostrarEstadisticas':
|
||||
|
||||
$usuario = Usuario::buscarPorId($_SESSION['idUsuario']);
|
||||
|
||||
if ($usuario instanceof Usuario) {
|
||||
|
||||
echo json_encode([
|
||||
'victorias' => $usuario->getVictorias(),
|
||||
'derrotas' => $usuario->getDerrotas(),
|
||||
'aciertos' => $usuario->getAciertos()
|
||||
]);
|
||||
|
||||
} else {
|
||||
|
||||
echo json_encode($usuario);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ include 'cabecera.php';
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Triviagmático</title>
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
+34
-7
@@ -28,6 +28,7 @@
|
||||
<!-- Tu CSS -->
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
<link rel="stylesheet" href="css/perfil.css">
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
@@ -67,7 +68,7 @@
|
||||
<!-- Nombre -->
|
||||
|
||||
<h1 id="nombre" class="nombre">
|
||||
tuNombre
|
||||
<?php echo $_SESSION['nombreUsuario'] ?>
|
||||
</h1>
|
||||
|
||||
|
||||
@@ -180,8 +181,8 @@
|
||||
<i class="bi bi-trophy-fill"></i>
|
||||
Victorias:
|
||||
|
||||
<strong>
|
||||
0
|
||||
<strong id="victorias">
|
||||
|
||||
</strong>
|
||||
|
||||
</div>
|
||||
@@ -192,8 +193,8 @@
|
||||
<i class="bi bi-x-circle-fill"></i>
|
||||
Derrotas:
|
||||
|
||||
<strong>
|
||||
0
|
||||
<strong id="derrotas">
|
||||
|
||||
</strong>
|
||||
|
||||
</div>
|
||||
@@ -204,8 +205,8 @@
|
||||
<i class="bi bi-bullseye"></i>
|
||||
Aciertos:
|
||||
|
||||
<strong>
|
||||
0
|
||||
<strong id="aciertos">
|
||||
|
||||
</strong>
|
||||
|
||||
</div>
|
||||
@@ -417,6 +418,32 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
'orden': 'mostrarEstadisticas'
|
||||
}
|
||||
}).done(function(respuesta) {
|
||||
console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
console.log(respuesta.error);
|
||||
} else {
|
||||
|
||||
$('#victorias').text(respuesta.victorias);
|
||||
$('#derrotas').text(respuesta.derrotas);
|
||||
$('#aciertos').text(respuesta.aciertos);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user