php - 仅显示 MySQL 列值计数

如何显示这个查询结果:

从MySQL到网页,就像这样:

我只想显示计数。我确实通过 PHP 运行了相同的查询,但它返回了“2”。 PHP代码如下

 <?php
    //Connection for database                                          
    $conn = mysqli_connect("localhost", "root", "aaaaa", "db");

    $query = "SELECT `gender`,COUNT(`gender`)  FROM `reg` GROUP BY `gender`";

        $result = mysqli_query($conn, $query); 
        
        if ($result) 
        { 
            // it return number of rows in the table. 
            $row = mysqli_num_rows($result); 
            
            if ($row) 
                { 
                    printf("" . $row); 
                } 
            // close the result. 
            mysqli_free_result($result); 
        } 
    
        // Connection close  
        mysqli_close($conn); 
?>

请注意,我已经完成了类似这样的其他答案 one但我真的找不到办法,我只希望计算值而不是表中所有行的总数,例如算作“男性”。

相关文章:

python - 将前导零添加到日期和时间字符串中的小时数

css - react/next.js 中的 * 选择器

typescript - 是否可以修改 TypeScript 中文字的推断类型?

docker - Docker 中 dotnet/aspnet :3. 1 的 list 条目中没有

reactjs - 如何强制更新功能组件?

docker - containerd 中的 docker volumes 是什么?

python - 如何在 Python 的 Tkinter 中使用 .create_image

flutter - 有什么方法可以将查询参数插入 flutter web 中的命名路由?

macos - M1 MAC 的 opencv 问题 - OpenCV imshow 不起作用

gpu - Spacy + GPU 给出错误 : GPU is not accessible. 库是