Welcome Guest, Not a member yet? Register   Sign In
How to get different user info when logged in.
#6

This is the the code that I use to get my Comments.

PHP Code:
/**
 * getComments ()
 * -------------------------------------------------------------------
 *
 * @param  $postId
 * @return array
 */
public function getComments($postId)
{
 
   $data = [];

 
   $this->db->where('post_id'$postId);

 
   $query $this->db->get('comments');

 
   if ($query->num_rows() > 0)
 
   {
 
       foreach ($query->result_array() as $row)
 
       {
 
           $data[] = $row;
 
       }
 
   }

 
   $query->free_result();

 
   return $data;


You can then display them similar to this.

PHP Code:
<h3>Comments</h3>
<?
php
if (count($comments))
{
 
   foreach ($comments as $key => $list)
 
   {
 
       echo "<b>Comment by ".$list['title'].":</b><br>\n";
 
       echo auto_typography($list['body']);
 
   }

 
   echo "<br>";
}
?>

I'am still building my new version, but maybe the above will help.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: How to get different user info when logged in. - by InsiteFX - 01-25-2018, 05:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB