0

I have some problem with these codes. I already declared notification but the error keeps showing.

Here's my code

 public function view_notification($id,$token= ''){
        $this->isLoggedIn();


    $data_applicant = array(
            // get data using email
        'token' => $token,
        'applicant_info' => $this->model->getApplicantInfo($this->session->userdata('email'))->row(),
        'notifications' =>  $this->model->notification($this->session->userdata('email'))->result_array(),
        'notification' =>  $this->model->all_notification($this->session->userdata('email'))->result_array(),

    );



    if ($this->session->userdata('position_id') == '3') { // Applicant
        $this->load->view('includes/applicant_header', $data_applicant);
        $this->load->view('applicant/notification/notifation', $data_applicant);
    }

   }

 }

Under view:

<div class="modal-body">
        <?php foreach($notification as $noti): ?>


      <h3>From: Administrator</h3><h5><?=$noti['notif_content']?></h5><p><?=$noti['date']?></p>
    <hr>


      <?php endforeach; ?>
    </div>

Need help thanks!

coder
  • 8,346
  • 16
  • 39
  • 53
Tristan
  • 71
  • 2
  • 10

1 Answers1

0

In your code PHP is not able to find any array named as $notification is is inside an array called $data_applicant

so please rewrite your for each as as

 <?php foreach($data_applicant['notification'] as $noti): ?>

This will work please try.

Pranav MS
  • 2,235
  • 2
  • 23
  • 50