Welcome Guest, Not a member yet? Register   Sign In
Selecting views
#1

[eluser]no_Ob[/eluser]
Hi there

I have got a very annoying problem which is looks like quite simple,but I can't figure it out.

I would like to choose the loaded view according to the database results.

Controller:
Code:
class Categories extends Controller {


    function index()
        {
         parent::Controller();
        
         $this->load->view('index');
         $this->load->view('partial/home_view');    
          $this->load->view('index2');    
            
        }

    function choice($platform,$what)
    {
        parent::Controller();
        
        $data['platform'] = $platform;
        $data['what'] = $what;
        
        
        $this->load->model('shopmodel');
        $result['query'] = $this->shopmodel->selectkonzol($data);
        
    
        $data[$platform] = 'T';
        $this->load->view('index',$data);
        
        
        if(!empty($result))
        {
        $this->load->view('products/games',$result);    
        }
        else
        {
        $this->load->view('products/noproduct',$database);
        }

        $this->load->view('index2');
    }
}

Model
Code:
class Shopmodel extends Model {

    function index()
    {
        // Call the Model constructor
        parent::Model();
            
    }

    function selectkonzol($data)
    {
        
    $platform   = $data['platform'];
    $what   = $data['what'];
    
    if($what=="games")
    {
    $query = "SELECT * FROM `games` WHERE `platform`='$platform'";
    }
    else
    {
        $query = "SELECT * FROM `products` WHERE `platform`='$platform' and 'productcat'='$what'";
    }
    
    
    $result=$this->db->query($query);
    return $result->result();
    }
}

If I have no results, it doesnt load the other viewSad

Why is this happening?


Messages In This Thread
Selecting views - by El Forum - 11-01-2008, 08:48 AM
Selecting views - by El Forum - 11-01-2008, 01:03 PM
Selecting views - by El Forum - 11-01-2008, 01:30 PM
Selecting views - by El Forum - 11-01-2008, 01:49 PM
Selecting views - by El Forum - 11-02-2008, 01:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB