I encountered this error when I pressed the Search button and I search the title The title and the date is showing fine on the table but not the abbrev and the professor any idea on what went wrong?
Here's my code:
View:
<?php
foreach ($actor as $project ) {
echo generateTableRow($project);
}
function generateTableRow($project)
{
$projectUrl = base_url("show_project?id=$project->proj_id");
$date = date('F d, Y (h:i A)', strtotime($project->date_uploaded));
$abbrev = ($project->abbrev);
$professor = ($project->professor);
$tableRow = '<tr>';
$tableRow .= "<td><a href=\"$projectUrl\">$project->title</td>";
//$tableRow .= "<td>$project->abbrev</td>";
$tableRow .= "<td>$abbrev</td>";
$tableRow .= "<td>$date</td>";
$tableRow .= "<td>$professor</td>";
$tableRow .= '</tr>';
return $tableRow;
Model :
public function search_title($title){
$this->db->select("*");
$this->db->from("projects_tbl");
$this->db->like("title", $title);
$query = $this->db->get();
if($query->num_rows() > 0 ){
return $query->result();
} else {
return $query->result();
Controller :
public function search_title(){
$this->load->model("Learning_model");
$title = $this->input->post('search');
if(isset($title) and !empty($title)){
$data['actor'] = $this->Learning_model->search_title($title);
$data['links'] = '';
$this->load->view('template/header1');
$this->load->view('Learning/browse' , $data);
$this->load->view('template/footer');
} else {
redirect($this->browse());
}
}
When you render the view, $project
s (items of the array $actor
) are objects and those don't have a property named abbrev
. Here the error you get (but that's quite obvious).
When your model generate $actor
, abbrev
and professor
are not part of "actors" so either the table you fetch data from doesn't contain those columns or have different names.
Couldn't help more with the code/info provided. Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.