The goal of this application is to be able to click on a link from one view to get data from another. The first view works just fine and I'm getting the correct PK as well. When I click the link I am having issues.
Getting a 'Message: Invalid argument supplied for foreach()' from this view:
<?php
echo "<h2>View</h2>";
foreach ($rows as $r){
echo '<br /><h3>'; echo $r->tHandle; echo'</h3>';
echo "<li>Sent at: "; echo $r->content; echo"</li><br />";
echo'<li>Created: '; echo $r->created; echo'</li><br />';
}
?>
This is the model and function where the DB query is taking place:
<?php
class Tweets_model extends CI_Model{
public function __construct() {
$this->load->database();
}
public function getTweetDetails($id){
$this->db->select('*')->from('tweets')->where('tweetId', $id);
$q = $this->db->get();
if($q->num_rows > 0){
foreach($q->result() as $row){
$data[]=$row;
}
return $data;
}
}
}
?>
Controller:
<?php
class Tweets extends CI_Controller{
public function __construct() {
parent::__construct();
$this->load->model('tweets_model');
}
public function details(){
$data['rows'] = $this->tweets_model->getTweetDetails($this->uri->segment(2));
$this->load->view('header');
$this->load->view('tweet_details', $data);
$this->load->view('footer');
}
}
?
>
Can anyone help me get past my error message?
Thanks.