0

I have a view that shows no. of urgent letters in the header as follows.

enter image description here

I used the following lines within my code and that is working fine. $UrgentLetters is defined in the Controller and that got from the model properly.

<div class="navbar-custom-menu">
     <ul class="nav navbar-nav">
            <li class="dropdown user user-menu">
                    <h4><i class="fa fa-refresh fa-spin fa-3x fa-fw" style="font-size:24px;color:white"></i>                
            You have <span class="label label-danger" >  <?php echo $UrgentLetters ? $UrgentLetters[0]['no_of_urgent']:0 ?> </span>&nbsp; No(s) of Urgent / Important Letters</h4>
            </li>
      </ul>
</div> 

Controller

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller
{
    function __construct() {
        parent::__construct();
        $this->load->model('Welcome_Model');
    }
    public function index()
    {     
        $where=Null;
        
        $meta=array(            
            'letterCount'=>$this->Welcome_Model->getLetterCount(),
            'branchCount'=>$this->Welcome_Model->getBranchCount(),
            'methodCount'=>$this->Welcome_Model->getMethodCount(),
            'classificationCount'=>$this->Welcome_Model->getClassificationCount(),
            'plCount'=>$this->Welcome_Model->getpendingLettersCount(),
            'letterFigures'=>$this->Welcome_Model->getLetterFigures($where),
            'pendingLetterCount'=>$this->Welcome_Model->getPendingCount(),
            'UrgentLetters'=>$this->Welcome_Model->getUrgentLetters()
            );
        
        //echo '<pre>'; print_r($meta);
        $this->load->view('header',$meta);
        $this->load->view('dashboard');
        $this->load->view('footer');
    }   
}
?>

But if I click on the green block, red block, pupal block or any other menu link that referred to other pages in my project, the following message outs.

enter image description here

I can't captured the issue with me. Can anyone help ?

Vivek Jain
  • 2,730
  • 6
  • 12
  • 27
MCIT Trends
  • 275
  • 1
  • 9

1 Answers1

1

I think you should write your variable with the empty condition like

if(empty($varibale))
     echo "0";
else 
    echo $varibale;

or there is a closing tag of the div is missing

  • @ Haseeb Ahad. Can you show the revised code with your suggestion. ?. div is properly ended. Because, if I remove the line

    You have   No(s) of Urgent / Important Letters

    , no error outs
    – MCIT Trends Aug 05 '20 at 05:03
  • @MCITTrends, it gives the output that undefined variable, so make sure the $UrgentLetters is rendering from the controllers on other pages as well. because I am sure it is not the error in the design but in the code. So kindly check the code in controller – Haseeb Ahad Aug 05 '20 at 05:16
  • @ Haseeb Ahad. But the controller is well defined as my edit – MCIT Trends Aug 05 '20 at 05:34