diff --git a/src/database.php b/src/database.php index 3e58d73..dc4e459 100644 --- a/src/database.php +++ b/src/database.php @@ -97,10 +97,21 @@ function listUsers($pdo) { return $result; } -function findUser($pdo, string $id) { +function fetchUserData($pdo, string $id) { $query = "SELECT * FROM usuario WHERE id=?"; $result = $pdo->prepare($query); - $result->execute([$id]); $data = $result->fetch(); + $result->execute([$id]); + $data = $result->fetch(); + return $data; +} + +function findUser($pdo, $input) { + $input = "%$input%"; + $query = "SELECT usuario.nombre, usuario.usuario, rol.nombre, usuario.correo, usuario.id, fecha_baja + FROM usuario, rol WHERE usuario.rol=rol.codigo AND (usuario.nombre LIKE ? OR usuario.usuario LIKE ? OR usuario.correo LIKE ?)"; + $result = $pdo->prepare($query); + $result->execute([$input, $input, $input]); + $data = $result->fetchAll(); return $data; } diff --git a/src/forms/user_edit_form.php b/src/forms/user_edit_form.php index 88263bd..8fd1acb 100644 --- a/src/forms/user_edit_form.php +++ b/src/forms/user_edit_form.php @@ -11,8 +11,9 @@ include '../database.php'; $pdo = connectDatabase(); - $data = findUser($pdo, $_GET["edit"]); - ?>