From 29c6d7bb6d8e614ee533d0933defda69904c3b34 Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 16 Jun 2020 22:50:35 +0200 Subject: [PATCH] List users from database --- README.org | 5 +- html/user.html | 52 -------------------- src/database.php | 16 ++++++- src/user.php | 79 +++++++++++++++++++++++++++++++ src/user_management.php | 18 +++++-- {html/static => static}/style.css | 10 ---- 6 files changed, 109 insertions(+), 71 deletions(-) delete mode 100644 html/user.html create mode 100644 src/user.php rename {html/static => static}/style.css (85%) diff --git a/README.org b/README.org index de9758c..3f174e7 100644 --- a/README.org +++ b/README.org @@ -5,6 +5,5 @@ This project consists of an Information System for a Medical Institution. ** Technologies - PHP -- MariaDB -- Nginx -- Docker +- Javascript (AJAX) +- MySQL diff --git a/html/user.html b/html/user.html deleted file mode 100644 index f5f5ef2..0000000 --- a/html/user.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - Gestión de usuarios - - - - - - - - - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
- - diff --git a/src/database.php b/src/database.php index 40ea492..8beb84c 100644 --- a/src/database.php +++ b/src/database.php @@ -13,7 +13,7 @@ function closeDatabase($pdo) { } function displayResults($query) { - while($row = $query->fetch()){ + foreach($query->fetch(PDO::FETCH_ASSOC) as $row){ echo $row . "\n"; } } @@ -96,4 +96,18 @@ function listAppointments($pdo, string $doctor) { findRows($pdo, "cita", "medico", $doctor); } + +function displayUsers($query) { + foreach($query->fetch(PDO::FETCH_ASSOC) as $row){ + echo $row["nombre"]; + } +} + +function listUsers($pdo) { + $query = "SELECT usuario.nombre, usuario.usuario, rol.nombre, usuario.correo FROM usuario + INNER JOIN rol ON usuario.rol = rol.codigo"; + $result = $pdo->query($query)->fetchAll(); + return $result; +} + ?> diff --git a/src/user.php b/src/user.php new file mode 100644 index 0000000..9d3562a --- /dev/null +++ b/src/user.php @@ -0,0 +1,79 @@ + + + + + + Gestión de usuarios + + + + + + + + + + + + + + + + + + + + + + + + + + +
NombreUsuarioRolCorreoAcciones
+ Editar + + Borrar +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + diff --git a/src/user_management.php b/src/user_management.php index a8a07e8..99f540e 100644 --- a/src/user_management.php +++ b/src/user_management.php @@ -1,8 +1,16 @@