1$search_keyword = '';
2if(!empty($_POST['search']['keyword'])) {
3 $search_keyword = $_POST['search']['keyword'];
4}
5$sql = 'SELECT * FROM posts WHERE post_title LIKE :keyword OR description LIKE :keyword OR post_at LIKE :keyword ORDER BY id DESC ';
6...
7...
8$pdo_statement = $pdo_conn->prepare($query);
9$pdo_statement->bindValue(':keyword', '%' . $search_keyword . '%', PDO::PARAM_STR);
10$pdo_statement->execute();
11$result = $pdo_statement->fetchAll();
1<?php
2$sth = $dbh->prepare("SELECT name, colour FROM fruit");
3$sth->execute();
4
5/* Fetch all of the remaining rows in the result set */
6print("Fetch all of the remaining rows in the result set:\n");
7$result = $sth->fetchAll(\PDO::FETCH_ASSOC);
8print_r($result);
9
10//Results:
11
12Array
13(
14 [0] => Array
15 (
16 [NAME] => pear
17 [COLOUR] => green
18 )
19
20 [1] => Array
21 (
22 [NAME] => watermelon
23 [COLOUR] => pink
24 )
25)
26 ?>