how can i include AND in this query?

Question

so i have this code with prepare and pdo.

$exe = $this->s->prepare("SELECT * FROM `items` WHERE `keywords` LIKE ?");
$exe->execute( ['%' . $keyword . '%']);

but i also have this but coded differently

if(isset($_GET["search"]))
  {
  $condition = '';
  $query = explode(" ", $_GET["search"]);
  foreach($query as $text)
{
  $condition .= "keywords LIKE '%".mysqli_real_escape_string($connect, $text)."%' AND ";
}
  $condition = substr($condition, 0, -4);
  $sql_query = "SELECT * FROM products WHERE " . $condition;
  $result = mysqli_query($connect, $sql_query);
  if(mysqli_num_rows($result) > 0)
{

how can i make the second one into PDO? because I want the AND but I'm not sure where to include it on the first code. The AND will help me because I'm trying to search multiple keywords. "KEYWORD1 AND KEYWORD2" then it should display that which is easy enough.


Show source
| pdo   | php   | search   2016-11-18 14:11 0 Answers

Answers to how can i include AND in this query? ( 0 )

Leave a reply to - how can i include AND in this query?

◀ Go back