CodeIgniter Forums

Full Version: mysql selects first result and not all?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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.

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

$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', ' = 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->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');
  $query = $this->db->get();
        return $query;

View File:
// 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
<?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!

El Forum

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