function get_other_ratings($user_id) { $ratings = array('rating', 'house_id'); $this->db->select('user_id'); $this->db->from('ratings'); $query = $this->db->get(); $queryArr = $query->result_array(); foreach ($queryArr as $row) { $this->db->select('user_id, house_id, rating'); $this->db->from('ratings'); $this->db->where('user_id', $row['user_id']); $query2 = $this->db->get(); $result2 = $query2->result_array(); foreach ($result2 as $row) { $house_id_and_rating = $row['rating']; if ($row['rating'] != 0 || $query2->num_rows() <= 0) { $data2[$row['house_id']] = $house_id_and_rating; //use the house id as the index for the ratings } } $final[$row['user_id']] = $data2; } return $final; require_once "recommend.php"; $re = new Recommend(); echo "<pre>"; print_r($re->getRecommendations($data, "3")); echo "</pre>"; }
<?php require_once "recommend.php"; require_once "sample_list.php"; $re = new Recommend(); echo "<pre>"; print_r($re->getRecommendations($books, "bruce")); echo "</pre>";