I'm trying to make it so that you can view the number of rows of something on my website, I converted the result into an array and then foreached it in the view, yet it calls the argument invalid.
As I said, I've tried the usual, passing on the data from the model to the controller and then to the view. I tried returning $query->num_rows(); as well as a count_all_results back to the controller array for it to be used in the view, both are invalid.
controller.php
$this->load->model('Main');
$data = array(
'getapps' => $this->Main->countapps()
);
$this->load->view('header', $data);
view.php
<?php foreach($getapps as $apps) {
?>
<a href="http://localhost/Dir/index.php/Controller/Apps" class="a-m" id="a-m-id">apps <strong><?php echo $apps; ?></strong></a>
<?php }
?>
model.php
public function countapps() {
$this->db->where('usedby', $_SESSION['uid']);
$this->db->get_where('apps', 'appstatus', 'Used');
$stmt = $this->db->count_all_results();
return $stmt;
}
What I expect to happen is for the view to display the number of rows, instead it tells me that the foreach argument is invalidly supplied.