php - Adding a Loop inside a loop -
please having issue loops, have loops of post content table, want add loop of content table previous loop after 2 post. succeeded in adding it, repeats first loop , add next loop.
below code sample
public function gettemplate() { $this->ci->load->library(['jobs']); if (! is_array($this->data)) { $this->getfeed(); } $storylist = ''; $count = 1; foreach ($this->data $storyid) { $count++; $this->ci->load->library('story'); $this->ci->story->setid($storyid); if ($this->profileid > 0) { $this->ci->story->setprofileid($this->profileid); } $storylist .= $this->ci->story->gettemplate(); //template content first loop if ($count % 3 == 0) { $this->ci->jobs->setlimit(2); foreach ($this->ci->jobs->getjobs() $job) { $jobdata['list_job_title'] = $job['job_title']; $jobdata['list_job_code'] = $job['job_code']; $jobdata['list_job_company'] = $job['company_name']; $jobdata['list_job_slug'] = $job['job_slug']; $jobdata['list_job_created'] = $job['job_created']; $jobdata['list_job_country'] = $job['country_name']; $jobdata['list_job_state'] = $job['state_name']; $storylist .= $this->ci->load->view('home/jobs/feeds-job-each',$jobdata, true);// template content second loop } unset($job); } } $storydata['story_timeline_id'] = $this->profileid; $storydata['story_list'] = $storylist; return $this->ci->load->view('home/feed/content',$storydata, true); }
Comments
Post a Comment