- 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>";
?>
ling 23.08.2011 10:26 # +4
in_wine_truth
Lure Of Chaos 23.08.2011 11:14 # +4
roman-kashitsyn 23.08.2011 10:38 # +1
CPPGovno 23.08.2011 11:07 # 0
Lure Of Chaos 23.08.2011 11:15 # +2
denis90 23.08.2011 11:45 # −1
у меня куча такого говна
guest 23.08.2011 21:35 # −1
denis90 23.08.2011 21:37 # −1
guest 23.08.2011 12:34 # −1
Vasiliy 23.08.2011 12:58 # 0
Велик ?
denis90 23.08.2011 13:10 # 0
<?php
function NewPDO()
{
$driver = "mysql";
$host = "localhost";
$db_name = "winestore";
try
{
$db = new PDO($driver.":host=".$host.";dbname=".$d b_name,'root','');
return $db;
}
catch(PDOException $e)
{
die("Error: ".$e->getMessage());
}
}
?>
Vasiliy 23.08.2011 13:47 # 0
CPPGovno 24.08.2011 08:40 # 0
Lure Of Chaos 24.08.2011 13:55 # 0
rO_ot 23.08.2011 14:19 # 0
хорошая замена mysql_connet(...) or die (mysql_error())
:)
AlexanderC 24.08.2011 01:25 # −1