I am trying to make a small search function to look at database using this code:
$searchQ = \'Li\';
$query = $connDB->prepare(\'SELECT * FROM topic WHERE
SQL
CREATE TABLE IF NOT EXISTS 'news'
(`id` int(9) NOT NULL auto_increment,
`title` text NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
insert into `items` (`id`, `title`) VALUES
(1, 'news title'),
(2, 'news title 2');
PHP
$connection = new PDO('mysql:host=localhost;dbname=YOUR_DATABASE_NAME','root','');
if (isset($_GET['store'])) {
$store = $_GET['store'];
if(!empty($store)){//condition you the remove karakter
$q=$connection->prepare("SELECT title FROM tbl_nes WHERE title LIKE :store");
$q->bindValue(':store','%'.$store.'%');
$q->execute();
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
echo $r->title,"
";
}
}
}
OUTPUT
1.news title
2.news title 2 ....