-
Notifications
You must be signed in to change notification settings - Fork 2
/
searchresult.php
186 lines (148 loc) · 4.67 KB
/
searchresult.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php include "txt/header.txt";?>
</div>
<div class="background">
<div class="wrapper">
<div class="searchBar">
<form id="myForm" action ="searchresult.php" method="GET">
<!-- Hela "sökfönstret" -->
<div id="searchField">
<p>Search <input type="text" name="search"/ required></p>
<!-- Söktext in i denna -->
</div>
<div id="serachButton">
<p><input type="submit" /> </p>
</div>
<div id="catergorySearch">
</div>
<div id="yearSearch">
</div>
<div id="sortBy">
<?php
include "radio.txt";
?>
</div>
</form>
</div>
<!-- php start-->
<?php
print("<p>Visar ANTAL resultat för sökordet ".$_GET['search']."...</p>");
?>
<div id="searchResult">
<!--
<table>
<tr>
<th>SetID</th>
<th>Item-ID</th>
<th>Setname</th>
<th>Image</th>
</tr>
-->
<?php
$setCounter = 0;
print("<p>Visarresultat för sökordet ".$_GET['search']."...</p>");
print('<div id="searchResult">');
$link = mysqli_connect("mysql.itn.liu.se" ,"lego","", "lego");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
include "search.php";
//Sidan ska söka på ett setId elr setnamn, ge förslag på matchande sökresultat. Skriver man något som matchar 100% så kmr detta bara. Annars visas de som matchar fast i ordning.
//Koppla upp <li> blog.php?order=asc;<li> blog.php?order=desc&limit=10 colors.Colorname LIKE "%'.$_GET["search"].'%" OR Setname LIKE "%'.$_GET["search"].'%" ;
//Search keyword thingy:
//Skriv ut alla poster
$urlBase="http://www.itn.liu.se/~stegu76/img.bricklink.com/";
print("<ul class='resultsList'>");
while($row = mysqli_fetch_array($result)) {
//För bild
$SetID = $row['SetID'];
$itemtype = 'S';
$filetype;
$setYear = $row['Year'];
if($row['has_largegif']OR $row['has_largejpg']){
$itemtype = 'SL';
if ($row['has_largegif'])
{
$filetype = ".gif";
}
else
{
$filetype = ".jpg";
}
}
else{
$itemtype= 'S';
if($row['has_jpg'])
{
$filetype=".jpg";
}
else
{
$filetype=".gif";
}
}
$fileName = $itemtype."/".$SetID.$filetype;
$imgsrc = $urlBase.$fileName;
$setname=$row['Setname'];
/*
print ("<div class = searchResult>");
print ("<tr><td><p>$fileName</p></td>");
print ("<td><p>$SetID</p></td>");
print ("<td><p>$setname</p></td>");
print("<td><img src= $imgsrc alt=$fileName></td></tr>");
print("</div>");
*/
print("<li>");
print("
<a href='set.php?searchID=$SetID'>
<div class='box'>
<div class='imgDiv'>
<img class = 'setImg' src= $imgsrc alt=$fileName>
</div> \n
<div class='searchResultInfo'>
<p><a href='set.php?searchID=$SetID'>$setname</a></p>
<p class= 'year'>$setYear</p>
</div> \n
</div>
</a>
");
print("</li>");
$setCounter += 1;
if( $setCounter == $itemsPerPage){
print("<p>HEJ!</p>");
$pageCounter += 1;
break;
}
}
print("</ul>");
mysqli_close($link);
?>
<!--</table>-->
<div id="arrows">
<form name="pagination" id="pagination" action ="searchresult.php" method="GET">
<button id="prev" name="prev" value="2" onclick="changePage();" /><</button>
<button id="next" name="next" value="2" onclick="paginationNext"/>></button>
</form>
</div>
<form id="pagination" name="pagination" action="searchresult.php" method="GET">
<input id="prev2" name="prev" type="button" value="4" onclick="changePage();">
<input type="submit" value="submit"/>
</form>
<script type="text/javascript">
function changePage()
{
//Change value of button
document.getElementById("prev").value = "3";
}
</script>
</script>
</div>
<!-- php slut? -->
<div id="searchFilter">
</div>
</div>
</div>
</body>
</html>