这个结构将有几个页面,只有 foreach 或 while 只显示最后一个结果,这个问题发生在我做了这个函数之后,我已经看到了几个问题,并且与 matriz 相关class Layout { private $sql, $row; private function set_layout($cond, $cond_r) { $this->sql = $this->select("*", "table", "".$cond."", array($cond_r)); foreach ($this->sql as $this->row) : return $this->row['name']; endforeach; } public function get_layout($cond, $cond_r) { return $this->set_layout($cond, $cond_r); }}echo $midia->get_layout("WHERE status != ? ORDER BY id DESC", 0);
1 回答
天涯尽头无女友
TA贡献1831条经验 获得超9个赞
我不确定,但我认为您正在寻找类似的东西:
class Layout {
private $sql, $row;
private function set_layout($cond, $cond_r) {
$this->sql = $this->select("*", "table", "".$cond."", array($cond_r));
$rows = array();
foreach ($this->sql as $this->row) :
$rows[] = $this->row['name'];
endforeach;
return implode($rows); //Return array of rows AFTER loop
}
public function get_layout($cond, $cond_r) {
return $this->set_layout($cond, $cond_r);
}
}
echo $midia->get_layout("WHERE status != ? ORDER BY id DESC", 0);
- 1 回答
- 0 关注
- 124 浏览
添加回答
举报
0/150
提交
取消