I have an index page that I'm enhancing with its search functionality by adding multiple choices of search. I can either type in a name in the search bar or click a link that would list items of certain group. All of this works, but I do get undefined variable error.
I am sending one variable with a value and another without in every search, but I am ordering the controller to pick both up from the URL. One will always be empty and the other might not be.
How do I "solve" this? Do I just suppress the error or ?
Controller
    public function index()
    {
        $search = $this->input->get('searchbox');
        $catsrch = $this->input->get('catname');
        $this->load->view('header');
            if (isset($search) && empty($catsrch)) {
                $this->searchByPostName($search);
            }
            elseif (isset($catsrch) && empty($search)) {
                $this->searchByCategory($catsrch);
            }
            else{
                $this->getAllPosts();   
            }
        $data['cat'] = $this->blog_model->getCategoryDropdown();            
        $this->load->view('categorysearch', $data);
        $this->load->view('footer');
    }
In the views, I'm doing stuff like this:
<?php
                foreach ($cat as $key) {?>
                    <tr><th><a href="<?php echo base_url()."welcome/index?searchbox=&catname=".$key['catname']; ?>"><?php echo $key['catname']; ?></a></th></tr>
                    <?php }?>
