Welcome Guest, Not a member yet? Register   Sign In
mysql selects first result and not all?
#1

[eluser]Zero-10[/eluser]
Hi everyone, I'm trying to figure out how to make pages save-able so it can be viewed at a later time. It works until another person saves it that article and at which point it's the first person to have.

Visual:
ID: 1; Title: This is a title [save for later]
Description: This is a description.

-----------------------------------------------------------------------------
Model:
Code:
$this->db->select('f.saveqaid, f.savecat, f.saveqdel, f.savequid, g.saveqbitid, b.user_id, b.username, p.article_id, COUNT(v.vote_article_id) AS votes, v.vote_id, v.vote_article_id, v.vote_published, p.page_url, p.page_title, p.page_tags, p.page_category, p.long_description, p.medium_thumb, p.published_time, c.category_id, c.parent_id, c.category_url, c.category_name');
   $this->db->from('article_list AS p');
   $this->db->join('article_votes AS v', 'v.vote_article_id = p.article_id', 'left');
   $this->db->join('phpbb_users AS b', 'p.author = b.user_id', 'left');
   $this->db->join('article_categories AS c', 'c.category_id = p.page_category', 'left');
   $this->db->join('save_bin AS f', 'f.saveqaid = p.article_id', 'left');
   $this->db->join('save_bin_type AS g', 'g.saveqbitid = f.savecat', 'left');
   $this->db->group_by('v.vote_article_id');
   $this->db->where('p.published_time >=', date('Y-m-d H:i:s', time() - 86400 * 7)); // Past Week
   $this->db->where('c.parent_id =', 4);
   $this->db->order_by('votes', 'desc');
   $this->db->limit(8);
  $query = $this->db->get();
        return $query;

View File:
Code:
// blah blah, code that doesn't related here
<?foreach ($pagesrecent->result_array() as $row3): ?>
// more styling code removed
<?if ($this->phpbb_library->isLoggedIn() === TRUE):?>
<?if ($row3['savequid'] != $id): ?>
// Save For later button appears
<?elseif ($row3['savequid'] == $id):?>
// Already saved stuff over here
<?endif?>
<?elseif //continues if user isn't logged in, not important code
// rest is removed for simplicity

If you can help, I'd greatly appreciate it!
#2

[eluser]Zero-10[/eluser]
I think I'm approaching this the wrong way. I think I need to somehow create another function that is called upon for every result. How exactly can I do this outside the view file? :O




Theme © iAndrew 2016 - Forum software by © MyBB