如何 运行 使用我在 php 中的查询进行计算
How to run a calculation with my query in php
如何将查询转换为方程式,然后打印答案。
我的模型
function get_bank()
{
$this->db->where('mem_id', $this->session->userdata("id"));
$query = $this->db->get('bank');
return $query->result();
}
我的观点
if (isset($records)) : foreach ($records as $row) : ?>
$row->i;
$row->c;
$row->n;
$row->p;
$row->r;
endforeach;
endif;
所以我不确定该怎么做,运行 使用我从查询中获得的数据的方程式
视图中的公式 ?
<?php $answer = $i * $n;
print "<h2>$answer</h2>";
;?>
如果您的循环中已经有了这些值,为什么不能简单地将它们写在 PHP 脚本中?
<?php
$x = $row->i / $row->c;
// and so on...
?>
或者如果您愿意:
<?php
$i = $row->i;
$c = $row->c;
$x = $i / $c;
// and so on...
?>
你的问题对我来说不是 100% 清楚,所以如果我没有回答你的问题,请说明你不理解的地方,我会进行编辑。
如何将查询转换为方程式,然后打印答案。
我的模型
function get_bank()
{
$this->db->where('mem_id', $this->session->userdata("id"));
$query = $this->db->get('bank');
return $query->result();
}
我的观点
if (isset($records)) : foreach ($records as $row) : ?>
$row->i;
$row->c;
$row->n;
$row->p;
$row->r;
endforeach;
endif;
所以我不确定该怎么做,运行 使用我从查询中获得的数据的方程式
视图中的公式 ?
<?php $answer = $i * $n;
print "<h2>$answer</h2>";
;?>
如果您的循环中已经有了这些值,为什么不能简单地将它们写在 PHP 脚本中?
<?php
$x = $row->i / $row->c;
// and so on...
?>
或者如果您愿意:
<?php
$i = $row->i;
$c = $row->c;
$x = $i / $c;
// and so on...
?>
你的问题对我来说不是 100% 清楚,所以如果我没有回答你的问题,请说明你不理解的地方,我会进行编辑。