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 {
- $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">';
- $output .= $row['imdb'] .'<br/>';
- $output .= ucfirst($row['genre']) .'<br/>';
- $output .= ucfirst($row['actors']) .'<br/>';
- $output .= $row['playtime'] . '<br/></div>';
- $output .= '<div id="trailer">' .$row['trailer'].'</div>';
- }
- }
- } else {
- echo 'Syötä hakusana';
- }
- ?>
- <!--End of normal section-->
- <div id="movie_background">
- <?php if(!empty($output)) {
- echo $output;
- }
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement