Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6880999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:03:07+00:00 2026-05-27T05:03:07+00:00

it’s me again! The problem I had with my code is that it displays

  • 0

it’s me again! The problem I had with my code is that it displays only one record instead of two. I already tried echoing the SQL statement and pasted on PHPMyAdmin and shows 2 records but on my end it doesn’t.

Here’s my controller:

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:

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();
} 

On my table the SQL statement shows
|user_id|post_id|body|
1 1 S
1 2 H

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:03:07+00:00Added an answer on May 27, 2026 at 5:03 am

    Try:

    $data['cont'] = '';
    //then foreach loop
    foreach($ws as $w):
    //then
    $data['cont'] .= '<li class="profile-thread-post">...
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I've runned in to a problem again that I can't solve on my
9 months later, the same problem shows up again. I've tried everything I can
I had done one publish to my MVC application. After that, I cannot debug
Got some basic problem again. I need to modify a function that previously returned
I've had this problem before before with no real resolution. It's happening again so
I have an intermittent problem with some code that writes to a Windows Event
::EDIT:: Ok folks, it seems that I'm an idiot after all. The problem had
Ive had a problem that I cant fix while creating an image carousel in
I'm facing this problem again and again, but can't find any solution (except mine,
I see this problem on and off again in my PHP coding, and I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.