LPCyber/tp5-files/webapp/helpdesk/print_clients.php

34 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2022-03-24 08:31:23 +01:00
<?php
session_start();
echo "Login is ". $_SESSION['login'];
echo "&nbsp;<a href=index.php?logout=1>Logout</a><br/><br/>";
require_once("../db.inc.php");
// Affichage de la table des clients
// Exécution de la requête SQL
$query = 'SELECT * FROM clients';
$result = pg_query($dbconn, $query) or die('Échec de la requête : ' . pg_last_error());
// Affichage des résultats en HTML
echo "<table border=1><tr><td>Name</td><td>Email</td><td>Comment</td><td>Message</td><td>Name</td><td>Email</td><td>Comment</td><td>Message</td><td>Update</td></tr>\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
$id=$line['id'];
$name=$line['name'];
$email=$line['email'];
$comment=$line['comment'];
$message=$line['message'];
echo "\t<tr><td>$name</td><td>$email</td><td>$comment</td><td>&nbsp;$message</td>\n";
echo "\t<form action=do_helpdesk.php method=post><td><input type=text name=name value=\"$name\"></td><td><input type=text name=email value=$email></td><td><input type=text name=comment value=\"$comment\"></td><td><input type=text name=message value=\"$message\"></td><td><input type=submit value=Update><input type=hidden name=id value=$id></td></form></tr>\n";
}
echo "</table>\n";
// Libère le résultat
pg_free_result($result);
// Ferme la connexion
pg_close($dbconn);
?>