Welcome Guest, Not a member yet? Register   Sign In
Nested View: Pass variable so that correct query results returned
#1

[eluser]Tumac[/eluser]
First: I am new to CI but understand already basic MVC concepts.

I think this is what I am trying to accomplish but not sure CI Subview thread

I have a nested view that is part of a tabset. The nested view is returning records of a query to the DB.

I would like to pass a variable from that nested view so that the records returned are only for that "key/variable".

I believe I may be missing something here as my "main()" function of my controller gets query results for the subview but does not use them on the "home" view.

Make sense? (prolly not...)

NESTED VIEW
Code:
<table class="tlctable">
    <tr>
        <th></th>
        <th>PO #</th>
        <th>Req Date</th>
        <th>Mill</th>
        <th>Contact</th>
        <th>Status</th>
    </tr>
    <tr>


&lt;?php
$lastcust=null;
echo $cusID;  
foreach($records as $row) {

?&gt;
  
    <tr>
        <td>&lt;?php echo form_checkbox('record','selected',FALSE); ?&gt;</td>
        <td>&lt;?php echo anchor("po/viewDetail/$row->poID",$row->poID); ?&gt;</td>
        <td>&lt;?php echo $row->shipReqDate; ?&gt;</td>
        <td>&lt;?php echo $row->millName; ?&gt;</td>
        <td>&lt;?php echo $row->conName; ?&gt;</td>
         <td>&lt;?php echo $row->status; ?&gt;</td>
    </tr>
    &lt;?php
    
$lastcust=$row->CusName;
} //end foreach



echo '</table>';

MAIN VIEW
Code:
&lt;?php
//$this->load->view('header');
include ('views/header.php');
?&gt;

<p><h2>Purchase Orders</h2></p>

<div id="tabs">
    <ul id="tabnav" >
&lt;?php    
$n=sizeof($cust);
$i=1;
foreach($cust as $cus) {
//for($i=0;$i<sizeof($cust);$i++) {
    if($i==1) { ?&gt;
        <li><a >cusID;?&gt;" id="tab_&lt;?php echo $cus->cusID;?&gt;" class="tab selected"><span>&lt;?php echo $cus->cusShort;?&gt;</span></a></li>
    &lt;?php
    } else {  ?&gt;
        <li><a >cusID;?&gt;" id="tab_&lt;?php echo $cus->cusID;?&gt;" class="tab"><span>&lt;?php echo $cus->cusShort;?&gt;</span></a></li>
&lt;?php  
    }  
    $i++;
}
?&gt;
    </ul>

&lt;?php
//for($i=0;$i<sizeof($cust);$i++) {
foreach($cust as $cus) {
    ?&gt;
    <div id="panel_&lt;?php echo $cus->cusID;?&gt;" class="panel">
       &lt;?php
       $cusID=$cus->cusID;
       $this->load->view("po/polist",$cusID);
       ?&gt;
    </div>
        
&lt;?php  
}
?&gt;
</div>


&lt;?php  
include ('views/footer.php');
?&gt;

CONTROLLER
Code:
function main() {
        $cusID="";
        if($query=$this->po_model->getPOinfo($cusID)) {
            $data['records']=$query;
            }        

        if($query=$this->po_model->getCustomers()) {
            $data['cust']=$query;
        }
        $this->load->view('po/home',$data);
    }

MODEL
Code:
function getPOinfo($cusID) {
        if($cusID == "") {
            $qry=$this->db->get('model_POHeader');
            return $qry->result();  
        } else {
            $this->db->where('cusID',$cusID);
            $qry=$this->db->get('model_POHeader');
            return $qry->result();
        }
    }


Messages In This Thread
Nested View: Pass variable so that correct query results returned - by El Forum - 12-16-2009, 06:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB