首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >过滤文件中的查询结果

过滤文件中的查询结果
EN

Stack Overflow用户
提问于 2017-11-05 05:14:29
回答 1查看 28关注 0票数 0

我在一个网站上工作。这是我当前代码的一部分:

代码语言:javascript
运行
复制
$num_cat_rec = mysqli_query($mysqli, "SELECT * FROM tb_revisiones_tor GROUP BY tipo_tor")
              or die (mysqli_error($dbh));

//display the results
while ($row_tor = mysqli_fetch_array($num_cat_rec))
{
    $puntos_tor_conseguidos =0; 
    ?>
    <div class="col-lg-4 col-xs-4">
        <!-- small box -->
        <div class="small-box bg-purple">
            <div class="inner">
                <?php 
                $usuario_tor = $row_tor['evaluado'] ;
                $tipo_tor = $row_tor['tipo_tor'];
                $puntos_tor_conseguidos = $puntos_tor_conseguidos+get_puntos_tor_conseguidos($usuario_tor,$tipo_tor);
                ?>
                <h3><?php echo $puntos_tor_conseguidos?></h3>
                <H4><?php echo $row_tor['nombre']?></h4>
            </div>
            <div class="icon">
                <i class="ion ion-ribbon-a"></i>
            </div>
            <a href="otros_rubros_reporte.php" class="small-box-footer">
                <?php echo $lang['MORE_INFO']?> <i class="fa fa-arrow-circle-right"></i>
            </a>
        </div>
    </div><!-- ./col -->
    <?php
}

这是当前的输出:

这是数据库结构和一些数据。

正如您可能看到的那样,我将数据组按字段nombre显示,如图片中所示为蓝色矩形。

我所需要的是显示每个组的字段值之和为大数,但只对某些用户(字段)显示。

所选用户的条件必须是:

代码语言:javascript
运行
复制
get_unit($row_tor['evaluado']= $_POST['un'];

get_unit(x)是PHP中的一个函数。

我该怎么做?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-05 06:09:32

  1. 将查询修改为: 选择SUM(朋TOS)作为puntos_sum,*从tb_revisiones_tor组中选择tipo_tor 得到每一组的和
  2. 添加条件以显示和: 如果($row_tor‘估价’=$_POST‘’un‘){ echo $row_tor’‘puntos_sum’;} 注意:使用==进行比较,而不是=
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47118404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档