view 使用
========================
foreach ($query->result_array() as $row)
{
echo $row['title'];
echo $row['name'];
echo $row['email'];
}
========================
controllers使用
========================
public function index()
{
$data['query'] = $this->sql_class_item->getall(); //顯示list
}
========================
models使用
========================
//列表
public function getall(){
return $this->db->query('select * from class_item order by class_item_id desc');
}
註:
$query = $this->db->query("YOUR QUERY");
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
echo $row->title;
echo $row->name;
echo $row->body;
}
}
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
echo $row->title;
echo $row->name;
echo $row->body;
}
}
沒有留言:
張貼留言