forked from jennyrudemo/lego-database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sida1.php
146 lines (101 loc) · 3.2 KB
/
sida1.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
<!doctype html>
<html lang="ca">
<head>
<meta charset="utf-8">
<title>Grupp1 Lego</title>
<meta http-equiv="refresh" content="300">
<link href="style.css" media="screen" rel="stylesheet" />
<script type="text/javascript">
window.onload = function() {
if(!window.location.hash) {
window.location = window.location + '#reload';
window.location.reload();
}
}
</script>
</head>
<body>
<form id="myForm" action ="sida1.php" method="GET">
<p>Search <input type="text" name="search"/></p>
<p><input type="submit" /> </p>
<!--<p><input onClick="javascript:timedRefresh(2000)" type="button">EYYYYY</a></p>-->
<?php
if(isset($_COOKIE['rbutton']) && $_COOKIE['rbutton']=='sbid')
{
print "<input type='radio' name='searchorder' value='sbname'> Search by Setname<br>";
print "<input type='radio' name='searchorder' value='sbid' checked='checked'> Search by SetID<br>";
}
else
{
print "<input type='radio' name='searchorder' value='sbname' checked='checked'> Search by Setname<br>";
print "<input type='radio' name='searchorder' value='sbid'> Search by SetID<br>";
}
?>
</form>
<table>
<tr>
<th>SetID</th>
<th>Item-ID</th>
<th>Setname</th>
<th>Image</th>
</tr>
<?php
$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;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
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/";
while($row = mysqli_fetch_array($result)) {
//För bild
$SetID = $row['SetID'];
$itemtype = 'S';
$filetype;
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 ("<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>");
}
mysqli_close($link);
?>
</table>
<form action ="sida1.php" method="GET">
<button name="prev"/><</button>
<button name="next"/>></button>
</form>
</body>
</html>