[eluser]JesseR[/eluser]
HERE IS MY CONTROLLER:
Code:
<?php
class Catalog extends Controller {
function Catalog()
{
parent::Controller();
/* $this->load->scaffolding('entries');*/
$this->load->helper('url');
$this->load->helper('form');
}
function index()
{
$data['query'] = $this->db->get('entries');
}
function products()
{
$this->db->where('CATEGORY','BECAS'/*$this->uri->segment(3)*/);
$this->db->like('DESCRIPT', '1 1/2"');
$data['query_item'] = $this->db->get('ITEMS');
foreach($data['query_item']->result() as $row):
$items['itemno'] = $row->ITEMNO;
$items['descript'] = $row->DESCRIPT;
echo "test";
/* Get Standard Item Selling Price */
$this->db->select('SELLPRIC');
$this->db->where('ITEMNO',$row->ITEMNO);
$this->db->where('MEAS_TYPE',1);
$data['query_price'] = $this->db->get('ITEM_MEASURE');
foreach($data['query_price']->result() as $row2):
$items['descript'] = $row2->SELLPRIC;
endforeach;
$itemsarray[] = $items;
$data = $itemsarray;
endforeach;
$this->load->view('product_view', $data);
}
}
?>
HERE IS MY VIEW:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Product Page></title>
</head>
<body>
<ol>
<?php foreach($data->result() as $row): ?>
<h3><?=$row->DESCRIPT?></h3>
<p><?=$row->WEBDESC?></p>
<p><?=$row->SELLPRIC?></p>
<p><?=anchor('blog/comments/'. $row->ITEMNO, 'Comments');?></p>
<hr />
<?php endforeach; ?>
</ol>
</body>
</html>
[quote author="jedd" date="1263446790"]
Am I right in assuming that item_eq.itemno = items.itemid - as in a foreign key (or a pretend one, at least).
Why can't you just do a JOIN here? If I'm wrapping my head around your problem properly (and I may well be missing something here - been a big day) it would probably also be easier for the view generation too. Is something like this thread - [/quote]
You are correct ITEM_EQ.ITEMNO = ITEMS.ITEMID. Any record in the ITEM_EQ table will always have a matching record in the ITEMS table. However there are various fields in each table such as CUSTMEMO1, etc... I need to retrieve. If the field CUSTMEMO1 is blank in the ITEM_EQ table I would have to display the field from ITEMS table.
I also need to retrieve the pricing information. If the field ITEM_EQ.SELLPRIC is true I need to use the items original sell price retrieved from a different table with different where arguments but if it is false i would display the price as the value in ITEM_EQ.SELLINGPRICE.
This is just a few examples I hope will make it more clear of my objectives here.
Once again I appreciate your help and look forward to your response.
[quote author="jedd" date="1263446790"]
Yeah - this could be a tad challenging. Is it feasible to apply this logic post-query?[/quote]
What do you mean post-query? Isn't that what I am referring to when I say I want to modify the returned query array results. Maybe I misunderstand the question. Please clarify.