I have a table in which I have some products and from them I want to get just unique values. I have a database in which I have values like Kia Picanto, Toyota Corolla, Kia Sportage, BMW Series 6, BMW Series 7 etc. Now I want to show values like Kia, Toyota, BMW. I am trying to search over the internet but didn't find any possible solutions so that's why I ma posting my question here to get the solution.I am using
SQL:
$sql = $db_con->prepare("SELECT `post_title` FROM `panel_product` WHERE `product_type` LIKE '%vehicle%' ORDER BY `post_title`");
$sql->execute();
$menufectures = $sql->fetchAll();
if (count($menufectures) > 0) {
foreach ($menufectures as $key) {
$brand = explode(' ', $key['post_title']);
$brand = $brand[0];
echo $brand.'<br />';
}
}
But I am getting Kia, Kia, Toyota, BMW, BMW. Please let me know if you have any solution for this.
Thanks