private function displayallsurveys() {
$this->load->database();
$sql = "SELECT * from survey";
$query = $this->db->query($sql);
$data = array();
if ($query->num_rows() > 0) {
$data = $query->result_array();
return $data;
} else {
return $data;
}
}
Passing to the View
$data = $this->displayallsurveys();
$this->load->view('SurveyPage', $data);
When i show it on the from end
<ul class="nav nav-sidebar">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Add new Survey</a></li>
<?php foreach ($data as $row) {
$SurveyTitle = $row['SurveyTitle'];
$SurveyId = $row['SurveyId'];
echo'<li id=' . $SurveyId . '><a href=' . $SurveyTitle . '>' . $SurveyTitle . '</a><li>';
}
?>
</ul>
I am getting undefined variable $data
Please someone help