Welcome Guest, Not a member yet? Register   Sign In
Retrieving problem..!!!
#1

[eluser]Roy MJ[/eluser]
Hi,
Can anyone tell me what im doing wrong. Im trying to get value from database for editing purpose. But error showing :

Code:
<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined variable: productcategory</p>
<p>Filename: mypackages/edit.php</p>

<p>Line Number: 98</p>

</div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Invalid argument supplied for foreach()</p>
<p>Filename: mypackages/edit.php</p>
<p>Line Number: 98</p>

The controller which im using to get the data is as follows:

Code:
$this->data['productcategory'] = $this->Mypackages_model->select_category();
$this->data['productstack'] = $this->Mypackages_model->select_stack();

The model part is as follows:

Code:
function select_stack()
    {
        $this->db->select('id,product_name');
        $this->db->order_by('product_name',"asc");
        $result_product = $this->db->get('product');
        return $result_product->result();
    }
    
function select_category()
    {
        $this->db->select('category_id,category_name');
        $this->db->order_by('category_id',"desc");
        $result_productcategory = $this->db->get('product_category');
        return $result_productcategory->result();
    }

The view is as follows:

Code:
<div>
<label>Product Group<span class="mandatory">*</span></label>
<select name="product_group" id="product_group" class="list_1">
  <option value="">- - Select Category - -</option>
&lt;?php foreach($productcategory as $row)    {?&gt;
    <option value="&lt;?php echo $row->category_name?&gt;" &lt;?php echo set_select('product_group',$row->category_name);?&gt; >&lt;?php echo $row->category_name?&gt;</option>
&lt;?php    }    ?&gt;
</select>
</div>
                            
<div>
<label>Stack<span class="mandatory">*</span></label>
<select id="product_id" name="product_id" class="list_1" >
<option value="">- - Select Stack - -</option>
&lt;?php    foreach($productstack as $row)    {?&gt;
<option value="&lt;?php echo $row->product_name?&gt;" &lt;?php echo set_select('product_id',$row->product_name);?&gt; >&lt;?php echo $row->product_name?&gt;</option>
&lt;?php } ?&gt;
<option value="11111"> - - Other - - </option>
</select>

</div>

Why is it showing undefined error?.. Its working fine for add page. This is while editing. But the select box values are from the same table and its value is static.


Messages In This Thread
Retrieving problem..!!! - by El Forum - 03-30-2011, 12:41 AM
Retrieving problem..!!! - by El Forum - 03-30-2011, 07:45 AM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:42 PM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:43 PM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:44 PM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:48 PM
Retrieving problem..!!! - by El Forum - 03-31-2011, 07:34 AM
Retrieving problem..!!! - by El Forum - 03-31-2011, 07:37 AM
Retrieving problem..!!! - by El Forum - 03-31-2011, 09:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB