Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit c9afc27

Browse files
committed
terminado
1 parent ab67ad3 commit c9afc27

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

backend/api.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,4 +847,26 @@ function getIdPokemon($nombre){
847847
echo "Error en la consulta: " . $mysqli->error;
848848
}
849849
}
850+
851+
function getPokemonesAdmin(){
852+
global $mysqli;
853+
854+
$id = $_GET['id'];
855+
856+
// Guarda la consulta en una variable
857+
$consulta = "INSERT INTO registro (id_usuario, id_pokemon) VALUES ($id, 1), ($id, 2), ($id, 3), ($id, 4), ($id, 5), ($id, 6), ($id, 7), ($id, 8), ($id, 9), ($id, 10), ($id, 11), ($id, 12), ($id, 13), ($id, 14), ($id, 15), ($id, 16), ($id, 17), ($id, 18), ($id, 19), ($id, 20), ($id, 21), ($id, 22), ($id, 23), ($id, 24), ($id, 25)";
858+
859+
// Envia la consulta y guarda el resultado
860+
$resulConsulta = $mysqli->query($consulta);
861+
862+
if($resulConsulta)
863+
{
864+
// Imprime el JSON como respuesta
865+
echo json_encode('Pokemones obtenidos');
866+
867+
} else {
868+
// Maneja el error en caso de que la consulta falle
869+
echo "Error en la consulta: " . $mysqli->error;
870+
}
871+
}
850872
?>

pokefinal/src/app/admin/admin.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ <h4 style="text-align: center;"><strong>AGREGAR POKEMON</strong></h4>
7373
</div>
7474
</div>
7575

76+
<div style="text-align: center; margin-top: 50px;">
77+
<button (click)="obtenerPokemones()" style="border-radius: 20px; padding: 10px;">OBTENER TODOS LOS POKEMONES</button>
78+
</div>
7679

7780
<div style="text-align: center; margin-top: 50px;">
7881
<button (click)="setPantalla(3)" style="border-radius: 20px; padding: 10px;">VOLVER</button>

pokefinal/src/app/admin/admin.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,12 @@ nuevoPokemon = {
167167
}
168168
);
169169
}
170+
171+
obtenerPokemones(){
172+
const idUsuario = this.dataService.getId(); // Obtener el ID del usuario desde el almacenamiento local
173+
174+
console.log("Se obtuvieron todos los pokemones!")
175+
176+
this.httpClient.get(`http://localhost/programacionweb/backend/api.php?accion=pokemonesAdmin&id=${idUsuario}`).subscribe()
177+
}
170178
}

0 commit comments

Comments
 (0)