forked from sierag/themoviedb-webfrontend
/
search.php
93 lines (86 loc) · 2.56 KB
/
search.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
<?
require_once('functions.php');
require_once('config.php');
require_once('db.php');
require_once('TMDb-PHP-API/TMDb.php');
if(isloggedin()){
$tmdb = new TMDb(TMDB_APIKEY);
$movies = $tmdb->searchMovie($_GET['search_keyword']);
if(count($movies['results'])>0) {
for($i=0;$i<count($movies['results']);$i++){
$ratedArr[] = $movies["results"][$i];
}
echo "<div class='row-fluid'>";
$i=3;
foreach($ratedArr as $r) {
$r['poster_path_w185'] = $tmdb->getImageUrl($r['poster_path'], 'poster', "w185");
$i++;
if($i>3) {
echo "</div><div class='row-fluid'>";
$i=0;
}
?>
<div class="item span3">
<a href="import.php?action=importsingle&tmdb_id=<?=$r["id"]?>">
<img src="<?=$r["poster_path_w185"]?>" width="100%" alt="" />
<div class="title">
<?=truncate($r["title"],20,' ','..')?>
<span class="year" style='float:left'>
<?=substr($r["release_date"],0,4)?>
</span>
<span style="float:right">
<?=$r["vote_average"]?>
</span>
</div>
</a>
</div>
<?
}
echo "</div>";
} else {
?>
<div class="item">
No result
</div>
<?
}
} else {
$query = "SELECT * from movies where title LIKE '%".mysql_real_escape_string($_GET['search_keyword'])."%' AND rating > 10 LIMIT 25";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
if(!mysql_num_rows($result)==0){
echo "<div class='row-fluid'>";
$i=2;
while ($row = mysql_fetch_assoc($result)) {
$i++;
if($i>2) {
echo "</div><div class='row-fluid'>";
$i=0;
}
?>
<div class="item span4">
<a href="<?=$row["url"]?>">
<div class="title"><?=$row["title"]?></div>
<img src="<?=$row["backdrop_path_w342"]?>" width="100%" alt="" />
<div class="title">
<?=truncate($row["title"],20,' ','..')?>
<span class="year" style='float:left'>
<?=substr($row["release_date"],0,4)?>
</span>
<span style="float:right">
<?=$row["rating"]/10?>
</span>
</div>
</a>
</div>
<?
}
echo "</div>";
} else {
?>
<div class="item">
No result
</div>
<?
}
}
?>