Friday 16 September 2016

How to fetch title of an product name from a database and send it to the header template in CodeIgniter

How to fetch title of an product name from a database and send it to the header template in CodeIgniter

Hello

If you want product name title in header title then follow this in incrustation.

In Model

function get_prductname($pid)
{
    $query = $this->db->query("SELECT * FROM table_name WHERE pid= '$pid' ");
   
    $count = count($result); # New

    return  $result = $query->row();
}
 
In Controller
 
public function prodcudetail($pid)
{
    $result = $this->Listing_model->get_prductname($pid); # Changed

    $data["page_title"] = $result[0]['field_name']; # Changed

        $this->load->view('includes/header',$data); # Changed
        $this->load->view('listings/listing_card',$data);
        $this->load->view('includes/footer');

}  
 
In View
 
php echo (!empty($page_title->productname)) ? $page_title->productname : ''; ?> # Changed   
 
This example of how setup  product name from a database and send it to the header template in CodeIgniter

No comments:

Post a Comment

Thank You For Comment