-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchmovies.php
77 lines (64 loc) · 2.21 KB
/
searchmovies.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
<?php
$page_title = "Search Results";
$body_id = "content";
require_once ('includes/header.php');
require_once('includes/database.php');
$name = $_GET['movie'];
//select statement
$query_str = "SELECT * FROM $tblMovies WHERE movie_name LIKE '%" .$name. "%' OR movie_bio LIKE '%" .$name. "%'";
//execut the query
$result = $conn->query($query_str);
//Handle selection errors
if (!$result) {
$errno = $conn->errno;
$errmsg = $conn->error;
echo "Selection failed with: ($errno) $errmsg<br/>\n";
$conn->close();
exit;
} else { //display results in a table
?>
<div class="container wrapper">
<br>
<h1 style="font-family: Montserrat-Bold" class="text-center moviedetails">Search Results</h1>
<?php
$num_rows = mysqli_num_rows($result);
if ($num_rows == 0) {
echo "<p style='color: red' class='lead text-center'>No results found for <strong>". $name . "</strong>. Please search again.</p>";
} else {
//insert a row into the table for each row of data
$i = 0;
while ( $result_row = $result->fetch_assoc() ) :
$i++;
if ($i == 1) :
?>
<div class="row">
<?php endif; ?>s
<div >
<div class="thumbnail">
<div class="caption movieBox1">
<div class="text-center movieBox1 ">
<a href="moviedetails.php?id=<?php echo $result_row['movie_id']?>">
<img width="210" height="315" src="<?php echo $result_row['movie_img'] ?>" />
</a>
</div>
<h3 style="font-family: Montserrat-Regular" class="text-center moviedetails">
<?php
echo $result_row['movie_name'];
?>
</h3>
</div>
</div>
</div>
<?php if ($i == 3) : ?>
</div>
<?php $i=0; endif; endwhile; ?>
</div>
</div>
<?php
}
// clean up resultsets when we're done with them!
$result->close();
}
// close the connection.
$conn->close();
?>