Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $dsn = 'mysql:dbname=movies;host=127.0.0.1';
- $user = 'root';
- $password = '';
- try {
- $pdo = new PDO($dsn, $user, $password);
- } catch (PDOException $e) {
- echo 'Connection failed: ' . $e->getMessage();
- }
- if(isset($_POST['submit']) && strlen($_POST['search']) > 1) {
- $searchq = $_POST['search'];
- $data = array();
- $sql = "SELECT * FROM `movie-info` WHERE `keywords` LIKE :keyword";
- $stmt = $pdo->prepare($sql);
- $stmt->execute(array(
- 'keyword' => '%' . $_POST['search'] . '%'
- ));
- if($stmt->rowCount() == 0) {
- echo 'Ei hakutuloksia!';
- exit();
- } else {
- $i = 0;
- $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
- foreach($results as $row) {
- $output = '<div id="title">
- '.ucfirst($row['title']).'
- </div>';
- $output .= '<div id="poster">
- '.$row['poster'].'
- </div>';
- $output .= '<div id="description">
- '.ucfirst($row['description']).'
- </div>';
- $output .= '<div id="info">
- '.$row['imdb'].'<br>
- '.ucfirst($row['genre']).'<br>
- '.ucfirst($row['actors']).'<br>
- '.ucfirst($row['playtime']).'<br>
- </div>';
- $output .= '<div id="trailer">
- '.$row['trailer'].'
- </div>';
- }
- }
- } else {
- echo 'Syötä hakusana';
- }
- ?>
- <!--End of normal section-->
- <div id="movie_background">
- <?phpif(!empty($output)) {echo $output;}?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement