- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
<?php
include_once "database.php";
$db = NewPDO();
$search = $db->prepare("SELECT w.wine_name as wine_name, w.year as wine_year, gv.variety as wine_variety, wn.winery_name as winery_name,r.region_name as region_name
FROM wine w
JOIN wine_variety wv ON w.wine_id = wv.wine_id
JOIN grape_variety gv ON wv.variety_id = gv.variety_id
JOIN winery wn ON w.winery_id = wn.winery_id JOIN region r ON wn.region_id = r.region_id
WHERE w.wine_name LIKE :in_wine_name AND wn.winery_name LIKE :in_winery_name AND r.region_name LIKE :in_region_name
ORDER BY w.wine_name ASC , w.year ASC , gv.variety ASC");
$wine_name = '%'.htmlspecialchars($_GET["wine"]).'%';
$winery_name = '%'.htmlspecialchars($_GET["winery"]).'%';
$region = '%'.htmlspecialchars($_GET["region"]).'%';
$search->bindValue(':in_wine_name',$wine_name,PDO::PARAM_STR);
$search->bindValue(':in_winery_name',$winery_name,PDO::PARAM_STR);
$search->bindValue(':in_region_name',$region,PDO::PARAM_STR);
$search->execute();
echo "<table>";
if ($search->columnCount() > 0)
{
echo "<tr align=\"center\">
<th>
Wine
</th>
<th>
Year
</th>
<th>
Variety
</th>
<th>
Winery
</th>
<th>
Region
</th>
</tr>";
while($row = $search->fetch())
{
echo "<tr align=\"left\">
<td width=\"80\">
".$row["wine_name"]."
</td>
<td width=\"50\">
".$row["wine_year"]."
</td>
<td width=\"90\">
".$row["wine_variety"]."
</td>
<td width=\"230\">
".$row["winery_name"]."
</td>
<td>
".$row["region_name"]."
</td>
</tr>";
}
echo "<tr>
<td colspan=\"5\">
".$search->rowCount()." records found matching your criteria.
</td>
</tr>";
}
else
{
echo "<tr><td>No records match your search criteria</td></tr>";
}
echo "</table>";
?>