Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 1.7: How to I grab and pass db data within this controller page
#1

[eluser]justmelat[/eluser]
I hope someone can help. I have been given a CI 1.7 app, what we want to do is create a method for designer to just drop values in without touching the code. That has caused problems ..so see the animator array below in the front class - for the heading, location_1, location_2 and office_id, I want these values pulled from the db,

I am fairly new to CI, and know i'm over thinking this, but I can't figure out how to pass the value to the array on this page.

I have created the db, created the front end gui and I have created a model like this:

Code:
<?php

class Slider_model extends CI_Model{
     function __construct()
    {
        parent::__construct();
    }
    
    public function get_img1()
    {
        $query = $this->db->query("SELECT * FROM frontPageAnimator where imgGrp = 'img1'");
        return $query->result();
    }
    public function get_img2()
        {
            $query = $this->db->query("SELECT * FROM frontPageAnimator where imgGrp = 'img2'");
            return $query->result();
    }
    public function get_img3()
        {
            $query = $this->db->query("SELECT * FROM frontPageAnimator where imgGrp = 'img3'");
            return $query->result();
    }
}

?>

Then on the page below and just above the annimator array, I put in
Code:
$image = array();
  $image_data = $this->Slider_model->get_img1();
                $row = $query->row_array();
  $image['title'] = '';

and here is where I am stuck

I want to do something like
Code:
$hdg = $row->heading;
$loc_1 = $row->location_1;
$loc_2 = $row->location_2;
$offid = $row->office_id;

then put the variables above in the array below:

Can anyone assist me with this? Any help/guidance would be greatly appreciated. Thank you.

============================================================
Code:
<?php require(APPPATH.'controllers/base_frontpage.php');

class Front extends Base_frontpage
{

/*front page*/
function index()
{
  //get page data for header and footer
  $page = $this->getPageData();
  
  
  $page['css'] = array(
   'include' => array(
   '/default/search.css',
   'search.css'
   ),
   'revision' => '1'
  );
  
  //include js files
  $page['js_files'] = array(
   'include' => array(
    '/jquery.nivo.slider.js',
    '/easypaginate.js',
    '/jquery.flip.min.js'
   ),
   'revision' => '1'
  );
  
  $front['animator'] = array(
   array(
    'heading'=>'Cambridge Standrige Complex',
    'location_1'=>'hartford/dale/groassh',
    'location_2'=>'hartford/dale/groassh',
    'office_id'=>'23-fkt-001'
   ),
   array(
    'title'=>'Reese Major Facility',
    'location_1'=>'wayford/crossvale/runnage',
    'location_2'=>'wayford/crossvale/runnage',
    'office_id'=>'569-wer-3689'
   ),
   array(
    'title'=>'Crimson Complex',
    'location_1'=>'grayson',
    'location_2'=>'grayson',
    'office_id'=>'789-dsfpodt-9514'
   )
  );

  
  $home['scroller']= $scroll;
  
  $this->load->view('header', $page);
  $this->load->view('left_col_view', $left);
  $this->load->view('frontpage_view', $home);
  $this->load->view('footer', $page);
}
}

/* End of file frontpage.php */
/* Location: ./system/application/controllers/cochran/frontpage.php */
================================================================================




Theme © iAndrew 2016 - Forum software by © MyBB