I have this code
<?php
$query1 = "SELECT users.id,
testtable_result.id as result_id,
testtable_result.user_id,
testtable_result.cad_id,
testtable_result.medication,
testtable_result.color,
testtable_category.category_id,
testtable_category.name
FROM users
INNER JOIN testtable_result
ON testtable_result.user_id=users.id
INNER JOIN testtable_category
ON testtable_result.cad_id=testtable_category.category_id
WHERE users.id = '{$userID}' AND color LIKE '%blue%';";
$result1 = query($query1);
confirm($result1);
if (row_count($result1) > 0) :
while($row1 = fetch_Array($result1)) {
$medication = $row1['medication'];
$data[] = $row1;
}
foreach ($data as $value) {
$categoryname = $value['name'];
$medication = $value['medication'];
$arrmaincatname = explode('(', rtrim($categoryname, ')'));
if($categoryname == "Saba"){
$datacat = $arrmaincatname[0];
$medicacat = $medication; ?>
In <?php echo $datacat; ?> category -- [<?php echo $medicacat ?>]
<?php
}} ?>
it shows result like this
In Saba category -- [ProAir RespiClick®] In Saba category -- [Proventil® HFA]
I want to remove all the duplicate results and want to show it like this.
In Saba category -- [ProAir RespiClick®, Proventil® HFA]