从MySQL回声SUM

时间:2019-12-18 07:34:50

标签: php mysql sum echo

<?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。怎么了?

1 个答案:

答案 0 :(得分:1)

$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;