Form query
This commit is contained in:
parent
28498993cb
commit
559703caa2
2 changed files with 127 additions and 0 deletions
57
pdo/classifica_pazienti/index.php
Normal file
57
pdo/classifica_pazienti/index.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$host = "192.168.1.20";
|
||||
$database = "ospedale";
|
||||
$user = "pdo";
|
||||
$password = "";
|
||||
|
||||
$datiMedici = [];
|
||||
|
||||
try {
|
||||
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||
echo "Connected successfully<br>";
|
||||
|
||||
$prepare = $connection->prepare("SELECT id, cognome, nome FROM medici");
|
||||
$prepare->execute();
|
||||
if ($prepare->rowCount() > 0) {
|
||||
$datiMedici = $prepare->fetchAll();
|
||||
}
|
||||
$connection = null;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTML</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||
>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container">
|
||||
<h1>Ricerca Pazienti per Medico</h1>
|
||||
<form action="result.php" method="POST">
|
||||
<label for="medici">Seleziona Medico</label>
|
||||
<select id="medici" name="Medici">
|
||||
<?php foreach ($datiMedici as $med) {
|
||||
echo "<option value='" . $med['id'] . "'>" . $med['cognome'] . " " . $med["nome"] . " </option>";
|
||||
} ?>
|
||||
</select>
|
||||
<input
|
||||
type="submit"
|
||||
value="Esegui Ricerca"
|
||||
/>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
70
pdo/classifica_pazienti/result.php
Normal file
70
pdo/classifica_pazienti/result.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$host = "192.168.1.20";
|
||||
$database = "ospedale";
|
||||
$user = "pdo";
|
||||
$password = "";
|
||||
|
||||
$datiPazienti = [];
|
||||
|
||||
try {
|
||||
$connection = new PDO("mysql:host=$host;dbname=$database", $user, $password);
|
||||
echo "Connected successfully<br>";
|
||||
|
||||
$prepare = $connection->prepare("SELECT cognome, nome, note FROM pazienti");
|
||||
$prepare->execute();
|
||||
if ($prepare->rowCount() > 0) {
|
||||
$datiPazienti = $prepare->fetchAll();
|
||||
}
|
||||
$connection = null;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die ("Error!: " . $e->getMessage() . "<br/>");
|
||||
}
|
||||
?>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>HTML</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||
>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="container">
|
||||
<form>
|
||||
<fieldset>
|
||||
<label>
|
||||
First name
|
||||
<input
|
||||
name="first_name"
|
||||
placeholder="First name"
|
||||
autocomplete="given-name"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Email
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
autocomplete="email"
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
value="Subscribe"
|
||||
/>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Loading…
Add table
Reference in a new issue