Note that there are some explanatory texts on larger screens.

plurals
  1. POLogic behind showing the previously liked buttons as Unlike
    primarykey
    data
    text
    <p>I have 2 different tables : reputation and posts POSTS have details related to it like post_id, user_id, post_content... and so on. REPUTATION have details like post_id and user_id. If a pair exists in the table then the post_id has been +1'ed by the user_id.</p> <p>On my homepage, i'm using pagination to display 5 posts/page and only fetching from the POSTS table. Further i'm trying to fetch the 'post_id' from REPUTATION table for the 'user_id' in $_SESSION.</p> <pre><code>public function index() { $this-&gt;load-&gt;model('themodel'); $this-&gt;load-&gt;library('pagination'); $config['base_url'] = site_url('trial/index'); $config['total_rows'] = $this-&gt;themodel-&gt;total_rows('posts'); $config['per_page'] = 5; //$config['display_pages'] = FALSE; $this-&gt;pagination-&gt;initialize($config); $offset = $this-&gt;uri-&gt;segment(3); $data['details'] = $this-&gt;themodel-&gt;list_posts($config['per_page'], $offset); $data['links'] = $this-&gt;pagination-&gt;create_links(); //Check for session and load the reputation data if($this-&gt;session-&gt;userdata('loggedIn') &amp;&amp; $this-&gt;session-&gt;userdata('user')) { //fetch reputation by user $data['repbyuser'] = $this-&gt;themodel-&gt;getrepbyuser(); } $this-&gt;load-&gt;view('home_view', $data); } </code></pre> <p>In the model part :</p> <pre><code>public function list_posts($limit, $start) { $this-&gt;db-&gt;select('post_id, user_id, post_title, post_content, total_reputation, post_time, total_reviews'); return $this-&gt;db-&gt;get('posts', $limit, $start)-&gt;result_array(); } public function getrepbyuser() { $this-&gt;db-&gt;select('post_id'); $this-&gt;db-&gt;where('user_id', $this-&gt;session-&gt;userdata('user')); $result = $this-&gt;db-&gt;get('reputation'); if($result-&gt;num_rows() &gt; 0) return $result-&gt;result_array(); } </code></pre> <p>Now on my homepage i'm traversing the <code>$details</code> array but i'm not sure how to match the results from both the table.</p> <p>If i'm doing anything wrong please guide. Any suggestion would be appreciated. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload