Created
December 3, 2019 21:45
-
-
Save parzibyte/0d76555ca5e1c72e99bbcacd73047559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Si no hay búsqueda, mostrar un arreglo vacío y salir | |
if (empty($_GET["busqueda"])) { | |
echo "[]"; | |
exit; | |
} | |
$bd = include_once "bd.php"; | |
$busqueda = $_GET["busqueda"]; | |
$sentencia = $bd->prepare("select * from mascotas where nombre like ?"); | |
$sentencia->execute(["%$busqueda%"]); | |
$mascotas = $sentencia->fetchAll(PDO::FETCH_OBJ); | |
echo json_encode($mascotas); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment