Welcome Guest, Not a member yet? Register   Sign In
Adding Categories....table join?
#7

[eluser]afterspark[/eluser]
Thanks again for the reply. I'm stuck on something simple that I can't get past....

Here is my query
Code:
$this->db->select('x.*', 'y.name AS category');
$this->db->join('articlecategories AS y', 'x.id = y.articleid');
$this->db->join('categories AS z', 'y.categoryid = z.id');
$this->db->where('x.articleSlug', $this->uri->segment(2));
$query2 = $this->db->get('articles AS x');

After this point, when I try to use the row_array() function to retrieve the article data, everything works fine except the category name. Here is an example

Code:
$row2= $query2->row_array();
            
$data['name'] = $row2['articleName'];
$data['description'] = $row2['articleDescription'];
$data['url'] = $row2['articleURL'];
$data['category'] = $row2['category'];

$this->load->view('article_view', $data);

I then use <?=$name?> and so on to display the data in the view. But for some reason I get a "Message: Undefined index: category" when I try to use the category name.

I feel like I'm really close to getting this, and your help have been very much appreciated.


Messages In This Thread
Adding Categories....table join? - by El Forum - 02-09-2008, 10:06 AM
Adding Categories....table join? - by El Forum - 02-09-2008, 10:28 AM
Adding Categories....table join? - by El Forum - 02-09-2008, 12:08 PM
Adding Categories....table join? - by El Forum - 02-09-2008, 09:58 PM
Adding Categories....table join? - by El Forum - 02-09-2008, 11:04 PM
Adding Categories....table join? - by El Forum - 02-09-2008, 11:32 PM
Adding Categories....table join? - by El Forum - 02-10-2008, 12:31 PM
Adding Categories....table join? - by El Forum - 02-10-2008, 07:17 PM
Adding Categories....table join? - by El Forum - 02-10-2008, 08:04 PM
Adding Categories....table join? - by El Forum - 02-10-2008, 08:15 PM
Adding Categories....table join? - by El Forum - 02-10-2008, 08:30 PM
Adding Categories....table join? - by El Forum - 02-10-2008, 09:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB