Hi friends,

I need a simple help or query for my search option in my website. I had a table which storing movie information. The rough form of table structure as follows.

Movie name | Director | Genre | Producer | Story line | Cast
| | | | |

When user type any word in search box and then hit "search " button I need to search on this complete table and shows the result. I am very new with these type of queries. Please help me

Thanks in advance

6 Years
Discussion Span
Last Post by jkon

A prepared statement query to do using PDO
Lets say that
Data Base name: $database
Host: $host
Data Base User Name: $dbUser
DB password: $dbUserPasswod
Table: $table
Search Term: $search

$db = new Pwf_Data_Db('mysql:dbname=$database;host=$host,$dbUser,$dbUserPasswod');
$query = "SELECT * FROM $table WHERE Movie_name LIKE ? OR Director LIKE ? OR Genre LIKE ? OR Producer LIKE ? OR Story_line LIKE ? OR Cast LIKE ?";
$statement = $db->prepare($query);
$result = $statement->fetchAll(PDO::FETCH_ASSOC);

So with that $result will be an array with all the results. Of course this code is just a sample and doesn’t handle any exception. Also a small advice… use a unified name concession for example Movie_Name but you can make your own as long as it is unified (in order your code to make sense) .

and also lets say that table fields you provided have _ between words


sorry not

$db = new Pwf_Data_Db('mysql:dbname=$database;host=$host,$dbUser,$dbUserPasswod');


$db = new PDO('mysql:dbname=$database;host=$host,$dbUser,$dbUserPasswod');
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.