Marc Ster
Marc Ster

Reputation: 2316

Prevent duplicates displaying categories from mysql database

I want to display a list of my categories. Like this:

and so on.. the problem is, that there are several categories named e.g "Cat 1", so the list will look like this:

How can i ensure there is only one of each category displayed?

I am doing this with php like this:

$abfrage = "SELECT * FROM Entries WHERE modulationstyp = 'Frequenzgespreizt'";
$ergebnis = mysqli_query($db, $abfrage)
OR die("Error: $abfrage <br>".mysql_error());

while($row = mysqli_fetch_object($ergebnis))
 {
echo "<li> $row->modulation </li>";

}
mysqli_close($db);
?>

This is for one Category..

Upvotes: 0

Views: 41

Answers (1)

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

Try distinct

$abfrage = "SELECT distinct modulation 
          FROM Entries WHERE modulationstyp = 'Frequenzgespreizt'";

Upvotes: 2

Related Questions