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

[eluser]aquary[/eluser]
Not sure since it's not the way I code.

Try this:

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()->result();
  /////////////////////////////////////////////////////////////////////////////////////////
  // you could var_dump() here to check if the returned result is good.  
  // var_dump($data['test']);
  

  $this->load->view('index', $data);
}
Code:
<? include("include/header.php"); ?>
<?
   if ($test)
   {
      foreach ($test as $row)
      {
         echo $row->user;
         echo $row->message;
         echo $row->created;
      }
   }
   else
      echo "Nothing to Display";
?>
<? include("include/footer.php"); ?>


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