I am retrieving post in CI using get_where query, my where variable is chaking for category is this.
I had pass the array of category to get_where query in foreach loop, but if there is no post under category, query gives me blank array in return.
My category array:
Array (
[0] => Array (
[0] => 341
[1] => Email Templates
[2] => email-templates
[3] => marketing
[4] => Email Templates
[5] => 340 )
[1] => Array (
[0] => 342
[1] => Newsletters
[2] => newsletters
[3] => marketing
[4] => Newsletters
[5] => 341 )
[2] => Array (
[0] => 343
[1] => e-Flyers
[2] => e-flyers
[3] => marketing
[4] => e-Flyers
[5] => 341 )
[3] => Array (
[0] => 344
[1] => Catalogs
[2] => catalogs
[3] => marketing
[4] => Catalogs
[5] => 341 )
[4] => Array (
[0] => 345
[1] => Email Stationery
[2] => email-stationery
[3] => marketing
[4] => Email Stationery
[5] => 341 ) )
above array is my $subcatid;
my controller:
public function index()
{
$data['post'] = $this->post->get_category_post($subcatid);
print_r($data['post']);
$this->load->view('frontend/post/category_post', $data);
}
in get_category_post; post function
function get_category_post($up_cat)
{
foreach($up_cat as $cat){
$query = $this->db->get_where('accmark_posts', array('up_sub_cat' => $cat[0]));
$result = $query->result();
print_r($result);
}
}
this function give me following array
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array ( )
Array (
[0] => stdClass Object (
[up_id] => 1
[user_id] => mediaexhibitor
[up_time] => 2015-02-15 16:24:11
[up_cat] => 340
[up_name] => RealEsta - Real Estate Email Marketing
[up_name_slug] => realesta-real-estate-email-marketing )
I want to remove this blank array() from result.