-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathescolheGeneroProcura.php
58 lines (51 loc) · 1.63 KB
/
escolheGeneroProcura.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!--Alterar para ser tipo checkbox-->
<html>
<head>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<title>Adiconar Pratos a Encomenda</title>
</head>
<body style="background-image:url(http://web.ist.utl.pt/ist170438/aux/fundo.jpg)">
<center>
<font size="5" color = "blue" ><b>Menu Escolher Genero a Procurar</b></font>
<br>
<form action="http://web.ist.utl.pt/ist170438/aux/mymdb.php">
<input type="submit" class="css_btn_class3" value="Inicio">
</form>
<br><h3>Escolha qual o genero a Procurar</h3>
<?php
try
{
$host = "db.ist.utl.pt";
$user ="ist170438";
$password = "zkkg9305";
$dbname = $user;
$db = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM Genero ;";
$options = array();
foreach($db->query($sql) as $row) {
$options[$row['nomeG']] = '<input type="checkbox" name="lista[]" value="'.$row['nomeG'].'" />';
}
$db = null;
}
catch (PDOException $e)
{
echo("<p>ERROR: {$e->getMessage()}</p>");
}
?>
<form action="mostraResultadosProcuraGenero.php" method="POST">
<?php
if (!$options) echo ' Nao ha Generos na BD';
else foreach ($options as $name => $input) echo '<label>'.$input.' '.$name.'</label><br />';
?>
<?php if(!$options): ?>
<button type="submit" class="css_btn_class3" disabled>Procurar</button>
<?php endif; ?>
<?php if(sizeof($options)> 0): ?>
<button type="submit" class="css_btn_class3">Procurar</button>
<?php endif; ?>
</form>
<br>
</center>
</body>
</html>