error:
A PHP Error was encountered Severity: Notice
Message: Trying to get property 'studentnumber' of non-object
Filename: users/edit_student.php
Line Number: 21
Backtrace:
File: C:\UniServerZ\www\student_monitoring_responsive\application\views\users\edit_student.php Line: 21 Function: _error_handler
File: C:\UniServerZ\www\student_monitoring_responsive\application\controllers\Students.php Line: 110 Function: view
File: C:\UniServerZ\www\student_monitoring_responsive\index.php Line: 315 Function: require_once
Here is my code: controllers
<?php
class Students extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('students_model');
}
public function students()
{
if(!$this->session->userdata('id'))
redirect('login/index');
$this->load->view('templates/header');
$data['students_info'] = $this->students_model->rows();
$this->load->view('users/students', $data);
$this->load->view('templates/footer');
}
public function edit_student($id)
{
if(!$this->session->userdata('id'))
redirect('login/index');
$this->form_validation->set_rules('studentno', 'Student Number', 'trim|required');
$this->form_validation->set_rules('fname', 'First Name', 'trim|required');
$this->form_validation->set_rules('lname', 'Last Name', 'trim|required');
$this->form_validation->set_rules('address', 'Address', 'trim|required');
$this->form_validation->set_rules('contact', 'Contact', 'trim|required');
$this->form_validation->set_rules('institution', 'Institution', 'trim|required');
$this->form_validation->set_rules('pgrade', 'Prelim Grade', 'trim|required');
$this->form_validation->set_rules('mgrade', 'Midterm Grade', 'trim|required');
$this->form_validation->set_rules('fgrade', 'Final Grade', 'trim|required');
$this->form_validation->set_rules('agrade', 'Average Grade', 'trim|required');
if ($this->form_validation->run()) {
$data = array(
'studentnumber' => $this->input->post('studentno'),
'firstname' => $this->input->post('fname'),
'middlename' => $this->input->post('mname'),
'lastname' => $this->input->post('lname'),
'address' => $this->input->post('address'),
'contact' => $this->input->post('contact'),
'institution' => $this->input->post('institution'),
'pgrade' => $this->input->post('pgrade'),
'mgrade' => $this->input->post('mgrade'),
'fgrade' => $this->input->post('fgrade'),
'agrade' => $this->input->post('agrade'),
);
$result = $this->students_model->edit_student($id, $data);
if ($result) {
$this->students();
}
} else {
$this->load->view('templates/header');
$data['student_info'] = $this->students_model->row($id);
$this->load->view('users/edit_student', $data);
$this->load->view('templates/footer');
}
}
}
?>
Here is my code: models
<?php
class Students_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->table = 'students';
}
public function row($id)
{
$where = array(
'id' => $id,
'is_deleted' => 0
);
$query = $this->db->get_where($this->table, $where);
return $query->row();
}
public function edit_student($id, $data)
{
$where = array(
'id' => $id,
'is_deleted' => 0
);
$this->db->update($this->table, $data, $where);
return true;
}
}
Here is my code: html
<title>Update Student | Student Monitoring</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>/css/edit.css">
</div>
</nav>
</article>
<main class="articlemain">
<div class="container-fluid">
<article class="art1">
<div class="divheader">
<b>Update Information</b>
</div>
<form action="" method="post">
<?= form_open('students/students', ['name' => 'studenttedit', 'autocomplete' => 'off']); ?>
<?php
if (validation_errors()) {
echo validation_errors();
}
?>
<div class="form-group">
<label><b>Student Number*</b></label>
<?php echo form_input(['name' => 'studentno', 'class' => 'form-control', 'value' => $student_info->studentnumber]); ?>
<?php echo form_error('studentno', "<div style='color:red'>", "</div>"); ?>
<label><b>First Name*</b></label>
<?php echo form_input(['name' => 'fname', 'class' => 'form-control', 'value' => $student_info->firstname]); ?>
<?php echo form_error('fname', "<div style='color:red'>", "</div>"); ?>
<label><b>Middle Name</b></label>
<?php echo form_input(['name' => 'mname', 'class' => 'form-control', 'value' => $student_info->middlename]); ?>
<?php echo form_error('mname', "<div style='color:red'>", "</div>"); ?>
<label><b>Last Name</b></label>
<?php echo form_input(['name' => 'lname', 'class' => 'form-control', 'value' => $student_info->lastname]); ?>
<?php echo form_error('lname', "<div style='color:red'>", "</div>"); ?>
<label><b>Address*</b></label>
<?php echo form_input(['name' => 'address', 'class' => 'form-control', 'value' => $student_info->address]); ?>
<?php echo form_error('address', "<div style='color:red'>", "</div>"); ?>
<label><b>Contact*</b></label>
<?php echo form_input(['name' => 'contact', 'class' => 'form-control', 'value' => $student_info->contact]); ?>
<?php echo form_error('contact', "<div style='color:red'>", "</div>"); ?>
<label><b>Institution*</b></label>
<?php echo form_input(['name' => 'institution', 'class' => 'form-control', 'value' => $student_info->institution]); ?>
<?php echo form_error('institution', "<div style='color:red'>", "</div>"); ?>
<label><b>Prelim Grade*</b></label>
<?php echo form_input(['name' => 'pgrade', 'class' => 'form-control', 'value' => $student_info->pgrade]); ?>
<?php echo form_error('pgrade', "<div style='color:red'>", "</div>"); ?>
<label><b>Midterm Grade*</b></label>
<?php echo form_input(['name' => 'mgrade', 'class' => 'form-control', 'value' => $student_info->mgrade]); ?>
<?php echo form_error('mgrade', "<div style='color:red'>", "</div>"); ?>
<label><b>Final Grade*</b></label>
<?php echo form_input(['name' => 'fgrade', 'class' => 'form-control', 'value' => $student_info->fgrade]); ?>
<?php echo form_error('fgrade', "<div style='color:red'>", "</div>"); ?>
<label><b>Average Grade*</b></label>
<?php echo form_input(['name' => 'agrade', 'class' => 'form-control', 'value' => $student_info->agrade]); ?>
<?php echo form_error('agrade', "<div style='color:red'>", "</div>"); ?>
</div>
<?php echo form_submit(['name' => 'submit', 'value' => 'Update', 'class' => 'btn btn-primary']); ?>
<?php echo form_close(); ?>
</form>
</article>
</div>
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
CodeIgniter is a framework that is known for requiring a minimum amount of customization to get it up and running. This allows those who choose it to work at a good pace. It has been updated many times since its inception in 2006. Now the most recent version is 4.0.3.
https://www.codeigniter.com/
CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language.
It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.
https://www.w3.org/TR/CSS/#css
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.