[英]List brand only once from table
I have a table of products. 我有一张产品表。 Each product has a field for 'brand' 每个产品都有一个“品牌”字段
I need to list all the brands on my page, but more than 1 product can have the same brand. 我需要在页面上列出所有品牌,但是一个以上的产品可以拥有相同的品牌。 How do i list the brand only once? 我如何只列出该品牌一次? Soi say that 5 products have the same brand name im not getting that brand name 5 times. Soi表示5个产品具有相同的品牌名称,而我没有5次获得该品牌名称。
$data=mysqli_query($link, "Select brand FROM products");
while($info=mysqli_fetch_array($data)){
$output .= '<div class="brands">';
$output .=$info["brand"];
$output.='</div>';
This outputs every instance of brand 输出品牌的每个实例
Thanks 谢谢
SELECT DISTINCT brand FROM products
这应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.