Guest User

Untitled

a guest
Jun 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. // Controller
  2. /////////////
  3.  
  4. function index()
  5. {
  6. // Nested Views
  7.  
  8. # Header Information
  9. $header_data['title'] = 'All Joboffers';
  10. $data['header'] = $this->load->view('mainpage/header_view',$header_data,TRUE);
  11.  
  12. # Content Information
  13. $content_data = array(
  14. 'heading' => 'Our Job Offers',
  15. #'display_jobs' => $this->jobs_model->getJobs()
  16. $query = $this->jobs_model->getJobs()
  17.  
  18. );
  19. # Load the View File
  20. $data['content'] = $this->load->view('jobs/index',$content_data,TRUE);
  21.  
  22. # Load Mainpage
  23. $this->load->view('mainpage_view',$data);
  24.  
  25. }
  26.  
  27. // Model
  28. ////////
  29.  
  30. function getJobs ()
  31. {
  32. $this->db->join('user_profile', 'jobs.author_id = user_profile.user_id');
  33.  
  34. $this->db->limit(4);
  35. $this->db->order_by('jobs.id','DESC');
  36. $this->db->where('status','1');
  37.  
  38. $query = $this->db->get('jobs');
  39. return $query->result_array();
  40. }
  41.  
  42. // View
  43. ///////
  44.  
  45. <?php
  46. /*$this->table->set_heading('City','Country', 'Company', 'Time');
  47.  
  48. foreach($query->result_array() as $row):
  49.  
  50. $this->table->add_row(
  51. '<a href="/jobs/detail/'. $row->id.'">'.$row->placeofwork.'</a>',
  52. '<a href="/jobs/detail/'. $row->id.'">'.$row->country.'</a>',
  53. '<a href="/jobs/detail/'. $row->id.'">'.$row->company_name.'</a>',
  54. '<a href="/jobs/detail/'. $row->id.'">Fulltime</a>'
  55. );
  56. endforeach;*/
  57. $fieldnames = array();
  58. foreach ($query as $val) {
  59. foreach ($val as $key => $value) {
  60. $fieldnames[] = $key;
  61. }
  62. }
  63. $this->table->set_heading(array_unique($fieldnames));
  64. $data['table'] = $this->table->generate($query);
  65.  
  66. ?>
Add Comment
Please, Sign In to add comment