预准备语句中的重复结果


duplicate results from prepared statement

    <select>
     <?php  
       require 'dbc.php';
       $getallnature_query = "SELECT strnature, Count(*) as total FROM nature_tbl GROUP BY strnature";
     $getallnature_stmt = $db->prepare($getallnature_query);
     $getallnature_stmt->execute();
     $getallnature_stmt->bind_result($allnature,$count);
     while ($getallnature_stmt->fetch()) {
       echo "<option>$allnature </option>";
                            }
 ?>
</select> 

问题。 我想将所有数据从我的自然表中获取到选择选项中。 我的问题是结果返回所有重复记录。

我使用 count(*( 来防止重复记录。 但仍然不起作用。 你能告诉我如何合并重复记录吗?

我的代码产生这样的结果

 <select>
     <option>Aircon unit</option>
     <option>Aircon unit</option>
     <option>Others </option>              
 </select>  

像这样尝试

SELECT DISTINCT strnature, Count(*) as total FROM nature_tbl GROUP BY strnature;