Welcome Guest, Not a member yet? Register   Sign In
Problem with data in view (SOLVED)
#1

[eluser]gazza7364[/eluser]
HI

I have a problem with the following code, which has been working fine until I updated Ubuntu today. Not sure if this is the cause or not. I also had a warning about date(), with timezone which I have now fixed. These problems both happend after the update.

View

Code:
<div id="year_wrapper" class="ui-corner-all">
<h1>Year</h1>
<div id="year">

        &lt;? foreach ($years as $year) : ?&gt;
  <div class="year" >&lt;?=$year->year?&gt;</div>
&lt;? endforeach; ?&gt;

</div>

I 'm getting Message: Undefined variable: year. Their is a onclick = getname( &lt;?= $year->user_id ?&gtWink but the post seems to remove it from the above code.


When I do

Code:
&lt;?php echo '<pre>' . print_r($years) . '</pre>'  ?&gt;
from the view the array shows the data, as follows:-



Array ( [0] => stdClass Object ( [user_id] => 29 [s_name] => Bloggs [f_name] => Joe[year] => Year 10 [full_name] => Joe Bloggs [ad_no] => 5405 ) [1] => stdClass Object ( [user_id] => 1 [s_name] => bloggs [f_name] => Joe [year] => Year 11 [full_name] => Joe Bloggs [ad_no] => 5243 ) [2] => stdClass Object ( [user_id] => 730 [s_name] => Joe [f_name] => blogs [year] => Year 7 [full_name] => Joe Bloggs [ad_no] => 5959 ) [3] => stdClass Object ( [user_id] => 3 [s_name] => bloggs [f_name] => joe [year] => Year 8 [full_name] =>Joe Bloggs [ad_no] => 5734 ) [4] => stdClass Object ( [user_id] => 5 [s_name] => Bloggs [f_name] => Joe [year] => Year 9 [full_name] => Joe Bloggs [ad_no] => 5584 ) )

but nothing shows when i use the foreach in the view as shown at the top of this page.
Any idea.

Controller

Code:
$data['years'] = $this->it_model->get_year();
  
        $this->load->view('it', $data);


Model

Code:
function get_year()  {


                $this->db->select();
                $this->db->group_by('year');
                $query = $this->db->get('user');


                if ($query->num_rows() > 0)
        {
                foreach ($query->result() as $row)
                {

                $data[] = $row;
        }
                        
        }
        return $data;
                
}


Thanks in advance.


Messages In This Thread
Problem with data in view (SOLVED) - by El Forum - 10-29-2013, 07:58 AM
Problem with data in view (SOLVED) - by El Forum - 10-29-2013, 07:01 PM
Problem with data in view (SOLVED) - by El Forum - 10-31-2013, 01:01 AM
Problem with data in view (SOLVED) - by El Forum - 10-31-2013, 01:22 PM
Problem with data in view (SOLVED) - by El Forum - 11-01-2013, 02:57 AM
Problem with data in view (SOLVED) - by El Forum - 11-01-2013, 05:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB