首页 > 解决方案 > 来自 mysql 的 Echo SUM

问题描述

<?php $q = $this->db->query("select SUM(pocet_dni) as pocet from holiday where teacher_id="._get_current_user_id($this));
                                 $pocet_dni = $row['pocet'];
                                    echo $pocet;
               ?>

我无法回显 SUM。怎么了?

标签: phpmysqlsumecho

解决方案


$pocet不存在。使用row_array().

$q = $this->db->query("select SUM(pocet_dni) as pocet from holiday where teacher_id="._get_current_user_id($this))->row_array();
$pocet = $q['pocet'];
echo $pocet;

推荐阅读