Answer the question
In order to leave comments, you need to log in
Checking data from one table to another CodeIgniter. How?
There is a function, in it there is a selection from the database, there is a field in the table, section.
This field stores the ID of data from another table.
The sections table stores sections.
On the page, the data, title, picture and section title are displayed. I'm looking for a section by id.
For example, in the bouquets table in the section id field, 1 is indicated, then the table is searched by id, then the name of this section is twitched.
If the section is deleted, and the bouquet has ID 1, then it starts swearing with the
Severity: Notice
Message: Trying to get property of non-object
Filename: bouquets/index.php
Line Number: 90
echo $sections->title;
if($this->data['list'] == 0){
$this->session->set_flashdata('null', 'Записей в базе данных не сущестует.');
} else {
//print_r($this->data['list']);
foreach($this->data['list'] as $value){
$list_id = $value->section;
}
$this->data['sections'] = $this->bouquets->getSectionID($list_id);
}
function getSectionID($list_id){
$this->db->where('id', int() $list_id);
$this->db->limit(1);
$query = $this->db->get('sections');
$rows = $query->result();
return isset($rows[0] ? $rows[0] : false);
}
Answer the question
In order to leave comments, you need to log in
foreach($this->data['list'] as $value){
$list_id = $value->section;
}
$this->data['sections'] = $this->bouquets->getSectionID($list_id);
Severity: Notice
Message: Trying to get property of non-object
Filename: bouquets/index.php
Line Number: 97
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question