Okay guys I am having a hard time understanding how to do a certain query.
This is what I am trying to accomplish:
I am trying to output DISTINCT brands from a query result. So when a user searches for instance "SHOE" I can output all of the shoes in my database, plus have a choice on the side where the user can select a certain brand to filter the results. I already can output all of the data I need from the MATCH AGAINST query, I just can't figure out how to do A query that can query my first query with PDO.
Here is what I have:
<?php
require_once 'login.php';
$db = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$usersearch=strip_tags($_POST['searchquery']);
$query=$db->prepare("SELECT * FROM products WHERE MATCH(description) AGAINST (? IN BOOLEAN MODE) OR MATCH(brand) AGAINST(? IN BOOLEAN MODE);SELECT DISTINCT brand FROM products");
$query->execute(array('+%'.$usersearch.'%','+%'.$usersearch.'%'));
$result=$query->fetchALL(PDO::FETCH_ASSOC);
?>
My problem is with the "SELECT DISTINCT brand FROM products"
.
Is this the correct way to perform multiple queries? Will this select each brand FROM THE FIRST QUERY
to the left of the semicolon or just perform the query on each row in the DB?
Any help would be appreciated.
I'm kind of at a stand still.