Welcome Guest, Not a member yet? Register   Sign In
Result display only one record
#1

[eluser]Unknown[/eluser]
Hello, it's me again! But the problem I have now is the query that I made only displays one record:

Here's my controller:

Code:
function index()
    {
        if($this->tank_auth->is_logged_in()):
            $data['title'] = 'Tes : Home';
            $data['record'] = $this->Profile_model->get_profile_by_id();
            
            
            $ws = $this->Wall_model->get_user_posts();
            foreach($ws as $w):
                
                
                 $data['cont'] = '<li class="profile-thread-post">
                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                            <tr>
                                <td width="75" class="valign-top">
                    <div id="post-avatar">
                    <img src="../../images/avatar.gif" width="74" height="74" />
                    </div>
                    </td>
                    <td width="15">&nbsp;</td>
                <td class="valign-top">
                            
                            <div id="post-div">
                                <div>';
                    $data['cont'] .= '<span class="title oswald blue cap">'.$w->fname.'</span><span class="title oswald red cap">'.$w->lname.'</span>';
        $data['cont'] .= '<p>'.$w->body.'</p>';
        $data['cont'] .= '<br/><br />
      <div class="floatLeft small-text grayLight">
       Posted 2 hours ago
      </div>
      
      <div class="social-links alignRight">

      </div>
     </div>';
                    $pid = $w->id;
                $comments = $this->Wall_model->get_user_comments($pid);
                //if(count($comments) > 0 ):
                $data['cont'] .= '<ul id="post-comments-div">';
                    foreach($comments as $c):
                        $data['cont'] .= '<li class="comment-entry">
       <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td class="valign-top comment-avatar alignLeft" width="55">
          <img src="../../images/avatar.gif" width="46" height="46" />
         </td>
         <td class="valign-top comment-post">
          <div>
           <span class="sub-title oswald blue cap">'.$c->fname.'</span><span class="sub-title oswald red cap">'.$c->lname.'</span>
          </div>
          <div class="small-text-11 comment-content">'.$c->comment;
        $data['cont'] .= '</div>
          <div class="comments-meta alignRight">
           <span class="lgray small-text">Posted 2 hours ago</span>
           <a href="#" class="uline like-link ">like</a> &nbsp;
          </div>
         </td>
        </tr>
       </table>
      </li>';
                    endforeach;
                    $data['cont'] .= '</ul>';
                //endif;
                    $data['cont'] .= '</td></tr></table></li>';  
            endforeach;
            
            $this->load->view('profile/index', $data);
        else:
            $this->session->set_flashdata('message', '<div class="error centerText">You are not logged in</div>');
            redirect('auth/login');
        endif;
    }

Here's my model:

Code:
function get_user_posts()
    {
        $uid = $this->tank_auth->get_user_id();
        
        $query = $this->db->query("SELECT a.*, b.* from user_profiles a inner join user_statuses b on a.user_id = b.user_id where b.user_id = $uid order by posted_date DESC");
        
        return $query->result();
    }

    function get_user_comments($pid)
    {
        $result = $this->db->query("SELECT * FROM user_statuses a
                                    INNER JOIN user_status_comments c ON a.id = c.post_id
                                    INNER JOIN user_profiles b ON b.user_id = c.user_id where a.id = $pid");
                
      
        
        return $result->result();
    }

What could've gone wrong? Please help.




Theme © iAndrew 2016 - Forum software by © MyBB