I’ve got a database and I’d like to show some results from it without getting duplicates
Example
<?php
$sql = "select * from my_table order by subcategory ASC";
$result = mysql_query($sql) or die($qry);
if (mysql_num_rows($result) == '0') {
echo "No subcategory";
} else {
while ($line = mysql_fetch_array($result)) {
echo $line[subcategory];
echo "<br>";
}
}
?>
It currently shows me all subcategories even if they are duplicated
Question: How i can filter the results so that it will only show a subcategory once even if it’s in there 4 times.
Do I need to add something to this code to shows only without duplicated?
$sql ="select * from rss order by subcategory ASC";
Use
GROUP BYSee the manual for more information: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html