-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.php
More file actions
125 lines (117 loc) · 5.02 KB
/
results.php
File metadata and controls
125 lines (117 loc) · 5.02 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<html>
<head>
<meta charset="UTF-8">
<script src="sorttable.js"></script>
<title>Cycle Part Price Checker</title>
<link rel="stylesheet" type="text/css" href="foundation-6/css/foundation.css">
<link rel="stylesheet" type="text/css" href="style.css">
<script>
function getTable() {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myNode = document.getElementById("resultstbody");
while (myNode.firstChild) {
myNode.removeChild(myNode.firstChild);
}
document.getElementById("resultstbody").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET","/tableGen.php?q="+document.getElementById("searchBox").value,true);
xmlhttp.send();
}
</script>
</head>
<body>
<header>
<div class="headerContainer">
<span class="headerTitle">
<a href="index.html">Cycle Part Price Checker</a>
</span>
</div>
</header>
<div class="maincontentwrapper">
<div class="mainContent">
<form action="" method="get">
<div class="row">
<div class="large-12 columns" style="padding-top:10px;">
<input id="searchBox" type="text" name="q" placeholder="Search..." onkeyup="getTable()">
</div>
</div>
</form>
<table class="prodTable sortable" role="grid">
<thead>
<th>Retailer</th>
<th>Product Name</th>
<th>Brand</th>
<th>Price (GBP)</th>
</thead>
<tbody id="resultstbody">
<?php
/**
* Created by PhpStorm.
* User: Adam
* Date: 15/03/2016
* Time: 17:12
*/
function test_input($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$search = test_input($_GET['q']);
$search = "%".$search."%";
require("mysqlinfo.php");
$conn = new PDO('mysql:host=localhost;dbname=cyclepartpricechecker_db;charset=utf8', $sqlusername, $sqlpassword, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$stmt = $conn->prepare("SELECT * FROM wiggleprods WHERE prodname LIKE :searchvalue");
$stmt->bindValue(":searchvalue", $search);
if ($stmt->execute()) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>".'<a href='."http://www.wiggle.co.uk/".">"."Wiggle"."</a>"."</td>";
echo "<td>".'<a href='.$row['produrl'].">".$row['prodname']."</a>"."</td>";
echo "<td>".$row['brand']."</td>";
echo "<td>".$row['prodpricegbp']."</td>";
echo "</tr>";
}
}
$stmt = $conn->prepare("SELECT * FROM bikediscountprods WHERE prodname LIKE :searchvalue");
$stmt->bindValue(":searchvalue", $search);
if ($stmt->execute()) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>".'<a href='."http://www.bike-discount.de/".">".'BikeDiscount.de'."</a>"."</td>";
echo "<td>".'<a href='.$row['produrl'].">".$row['prodname']."</a>"."</td>";
echo "<td>".$row['brand']."</td>";
echo "<td>".$row['prodpricegbp']."</td>";
echo "</tr>";
}
}
$stmt = $conn->prepare("SELECT * FROM crcprods WHERE prodname LIKE :searchvalue");
$stmt->bindValue(":searchvalue", $search);
if ($stmt->execute()) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>".'<a href='."http://www.chainreactioncycles.com/".">".'Chain Reaction Cycles'."</a>"."</td>";
echo "<td>".'<a href='.$row['produrl'].">".$row['prodname']."</a>"."</td>";
echo "<td>".$row['brand']."</td>";
echo "<td>".$row['prodpricegbp']."</td>";
echo "</tr>";
}
}
}
?>
</tbody>
</table>
</div>
</div>
</body>
</html>