了解老师和校长的意见



我试图让老师和校长的评论出现在视野中,但都无济于事。

这是一个学校网络应用程序,家长可以在其中查看各自孩子的结果。分数正下方是老师和校长的评论。

现在,这些评论出现在学生的视野中,但我很难让它出现在家长的视野中。

这是模型:

Comment_model.php

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Comment_model extends CI_Model {
public function __construct() {
parent::__construct();
$this->current_session = $this->setting_model->getCurrentSession();
$this->current_session_name = $this->setting_model->getCurrentSessionName();
$this->start_month = $this->setting_model->getStartMonth();
}
public function TeacherComment($data) 
{
$this->db->insert('teacher_comments', $data);
return $query = $this->db->affected_rows();
}
public function  UpdateTeacherComment($data, $id)
{
$this->db->where('id', $id);
$this->db->update('teacher_comments', $data);
return $query = $this->db->affected_rows();
}
public function GetTeacherComment($student_id, $session_id) 
{
$this->db->select('*');
$this->db->where('student_id', $student_id);
$this->db->where('session_id', $session_id);
return $this->db->get('teacher_comments')->row();
}
public function PrincipalComment($data) 
{
$this->db->insert('principal_comments', $data);
return  $this->db->affected_rows();
}
public function  UpdatePrincipalComment($data, $id)
{
$this->db->where('id', $id);
$this->db->update('principal_comments', $data);
return $query = $this->db->affected_rows();
}
public function GetPrincipalComment($student_id, $session_id) 
{
$this->db->select('*');
$this->db->where('student_id', $student_id);
$this->db->where('session_id', $session_id);
return $this->db->get('principal_comments')->row();
}
}

我正在与之抗争的控制器:

$data['teacher_comment'] = $this->Comment_model->GetTeacherComment($id, $student_session_id);
$data['principal_comment'] = $this->Comment_model->GetPrincipalComment($id, $student_session_id);

如何正确将其置于功能中?

观点:

<span> CLASS TEACHER'S REMARK: 
<u style="text-transform: uppercase;"><?php echo $teacher_comment->teacher_comment; ?> </u>
</span><br>
<br>
<span>PRINCIPAL REMARK: 
<u style="text-transform: uppercase;"><?php echo $principal_comment->principal_comment; ?></u> 
</span>

假设这是您的控制器文件。

class customview extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model("Comment_model");
}
public function yourViewFunction()
{
// get your $id and $student_session_id
$data['teacher_comment'] = $this->Comment_model->GetTeacherComment($id, $student_session_id);
$data['principal_comment'] = $this->Comment_model->GetPrincipalComment($id, $student_session_id);
$this->load->view('your_html_view',$data); //this is the view file name without php 
}
}

现在在你的 html 视图中,你可以像这样调用:

print_r($teacher_comment); //you can view the array or object get from model
print_r($principal_comment); //you can view the array or object get from model

相关内容

  • 没有找到相关文章

最新更新