i'm having category column in my database, i have to list only unique category by using $wpdb->get_results
how can i filter it? see code below...
<?php
global $wpdb;
$table_name = $wpdb->prefix . 'servicer';
$results = $wpdb->get_results("SELECT * FROM " . $table_name . " WHERE is_deleted = 0", ARRAY_A);
?>
<ul class="list-unstyled">
<?php
foreach($results as $key => $rec)
{
echo "<li>" . $rec['category'] . "</li>";
}
?>
</ul>
current result...
cat1
cat1
cat1
cat2
cat3
cat4
cat4
expected result... cat1 cat2 cat3 cat4
Used GROUP BY
OR Used DISTINCT