I don't really understand what your question is, but I'm guessing you don't know how to add the %
? If so, try this:
$stmt = $db->prepare("SELECT * FROM table_1 WHERE name LIKE ? ORDER BY bid DESC");
$stmt->bindValue(1, "%{$_GET['s']}%", PDO::PARAM_STR);
$stmnt->execute();
// fetch and win! :-)
A little explanation:
PDO will quote and escape the parameter ?
appropriately. This means, that if you are binding hello
, PDO will substitute ?
with 'hello'
(note the quotes). Therefore, in order to have the %
inside the quotes, you will have to add them to what is binded, in this case $_GET['s']
.