im trying to display only one value of my database if the value is duplicate/multiple or have the same value in another row
example database
id | name | section
1 | ron | ABC
2 | mark | B12
3 | nick | B12
this my php code:
$sql = "SELECT * FROM myusers";
$result = mysqli_query($conn, $sql);
while($rows = mysqli_fetch_array($result))
{
echo "$rows['section']";
}
Output : ABC B12 B12
i want output like this ABC B12
Since you're only using one column, just select that column. Then if you apply the DISTINCT
keyword there will be no duplicates:
$sql = "SELECT DISTINCT `section` FROM `myusers`";
You would need to use the DISTINCT parameter in your Queen. Here is an article with how to: https://www.dofactory.com/sql/select-distinct
Try this
$sql = "SELECT * FROM myusers GROUP BY section";