Codeigniter如何在视图中显示结果函数

时间:2016-07-11 15:32:54

标签: codeigniter view controller codeigniter-3

如何在视图SELECT dt.name FROM daily_tracking dt WHERE dt.completed BETWEEN CURDATE() - INTERVAL 14 HOUR AND CURDATE() + INTERVAL 10 HOUR;

中显示function day_s()的结果
just_organize/administrador/index

1 个答案:

答案 0 :(得分:1)

JUst在索引中添加以下行:

在视图中使用$ greetings变量

 public function index()
{
  $data['greetings'] = $this->day_s();
  $this->load->view("layouts/header");
  $this->load->view("layouts/navbar");
  $this->load->view("just_organize/administrador/index", $data);
  $this->load->view("layouts/footer");
}

您的day_s函数应返回$ greeting:

 public function day_s(){
  $time = date("H");
  $timezone = date("e");
  if ($time < "12") {
    $greeting= "Good morning";
  } else
  if ($time >= "12" && $time < "17") {
    $greeting= "Good afternoon";
  } else
  if ($time >= "17" && $time < "19") {
    $greeting= "Good evening";
  } else
  if ($time >= "19") {
    $greeting= "Good night";
  }
  return $greeting;
 }