Welcome Guest, Not a member yet? Register   Sign In
Simple foreach loop not working (code)
#1

[eluser]David Mitchell[/eluser]
Controller
Code:
//Home
function index()

/////////////////////////////Gets Message Data//////////////////////////////////////
  $userid = $this->session->userdata('id');
  $this->db->select('*')->from('message')->where('user', $userid);
  $data['test'] = $this->db->get();
  /////////////////////////////////////////////////////////////////////////////////////////  
  

  $this->load->view('index', $data);
}

index.php view file
Code:
<? include("include/header.php"); ?>
  

  <?php
  if ($test->num_rows() > 0)
  {
    foreach ($test->result() as $row)
    {
     echo $row->user;
     echo $row->message;
     echo $row->created;
    }
    echo "Nothing to Display";
  }
         ?>

<? include("include/footer.php"); ?>

Its not displaying anything, and the database is working fine. Have I done something Wrong?

David


Messages In This Thread
Simple foreach loop not working (code) - by El Forum - 02-17-2012, 07:53 AM
Simple foreach loop not working (code) - by El Forum - 02-17-2012, 07:59 AM
Simple foreach loop not working (code) - by El Forum - 02-17-2012, 08:46 AM
Simple foreach loop not working (code) - by El Forum - 02-17-2012, 09:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB