如何将查询转换为方程式,然后打印答案。
我的模型
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%清楚,所以如果我没有回答你的问题,请说明你不明白的地方,我会进行编辑。