Welcome Guest, Not a member yet? Register   Sign In
Trying to figure out how to get related portfolios
#3

Get the category ID of the portfolio they're looking at, and pass it to get_relatedportfolios().

In your controller:
PHP Code:
// assuming the current portfolio is in an array called $portfolio[] and assuming your model is called portfolio_model
$relatedportfolios $this->portfolio_model->get_relatedportfolios($portfolio['category_id']); 

In your model:
PHP Code:
public function get_relatedportfolios($category_id) {
    
$this->db->select('*');
    
$this->db->from('cms_portfolio');
    
$this->db->where('category_id'$category_id);
    
$this->db->limit(5);
    
$query $this->db->get();
    return 
$query->result();

Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
Reply


Messages In This Thread
RE: Trying to figure out how to get related portfolios - by RobertSF - 02-25-2016, 12:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB