Got a column (department) in database with text values separated with comma
Row1
id
1
department
HR,Finance,Utilities
Row2
id
2
department
HR,Finance
I need a query that will display these only once if they are present.
I am getting these but they are being repeated. In my example Utilities shows up once, but HR and Finance show up twice in my list.
What I have now.
SELECT DISTINCT department FROM tbl_video ORDER BY department DESC;
while ($department_query_row = mysql_fetch_array($department_query_result)) {
$dept_list_output = explode(",", $department_query_row['department']);
foreach ($dept_list_output as $item) {
<li><a href="search_dept.php?department=<?php print "$item"; ?>"><?php print "$item"; ?></a></li>
}
}
Thanks