php - 来自 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。怎么了?
解决方案
$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;
推荐阅读
- html - 使列内的元素保持在底部
- gitlab - 错误:before_script 配置应该是一个字符串数组
- c# - 在具有多个页面的一个数据网格视图上显示 SQL SERVER 查询的结果
- google-cloud-platform - 是否可以从同一个 Google 存储桶中提供不同的静态网站?
- php-7.2 - PHP 从 5.4 升级到 7.2
- sql - 如何从返回的子查询中选择没有值的记录(具有逗号分隔值)?
- javascript - 让分页更好一点 Vuejs
- arduino - 为arduino重写SdFat中的行
- concurrency - 线性化和静态一致性有什么区别?
- configuration - 如何更改 zpool 的默认 zfs 选项?