Welcome Guest, Not a member yet? Register   Sign In
Cannot Pass More than two variable to view
#1

Hello,
 I try to get total of price column in personal assets table. But I have below error.. 

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: employee/inventory.php
Line Number: 61
Backtrace:
File: C:\wamp64\www\MY\admin\application\views\employee\inventory.php
Line: 61
Function: _error_handler

File: C:\wamp64\www\MY\admin\application\controllers\Employee.php
Line: 223
Function: view

File: C:\wamp64\www\MY\admin\index.php
Line: 315
Function: require_once


My Model: 

PHP Code:
<?php

Class Employee_model extends CI_model
{
    public function 
__construct()
    {
        
parent:: __construct();
    }

public function 
view_data($id)
 
   {
 
       $query $this->db->query("SELECT
               sgh.employee.id,
               sgh.employee.employee_name,
               sgh.employee.designation,
               sgh.employee.join_date,
               sgh.employee.b_day,
               sgh.employee.address,
               sgh.employee.mobile_number,
               sgh.employee.photo,
               sgh.company.company_name,
               sgh.employee.company_id
               FROM
               sgh.company,
               sgh.employee WHERE sgh.employee.company_id=sgh.company.id AND sgh.employee.id='
$id'");
 
       $employee_data $query->row();
 
       return $employee_data;

 
   }

 
   public function view_inventory($id){
     
   $query $this->db->query("SELECT sgh.inventory.id,
                                    sgh.inventory.item_name,
                                    sgh.inventory.price,
                                    sgh.inventory.qty,
                                    sgh.inventory.serial_number,
                                    sgh.inventory.product_key,
                                    sgh.employee.id,
                                    sgh.employee.employee_name
                                  FROM sgh.inventory,
                                  sgh.employee WHERE sgh.inventory.employee_id=sgh.employee.id AND sgh.employee.id='
$id'");
     
   $item_data $query->result_array();
 
       return $item_data;
 
   }

 
   function employee_spends($id)
 
   {
 
       $query $this->db->query(" SELECT SUM(price) FROM inventory WHERE employee_id='$id'");
 
       $row $query->row();
 
       return $row;
 
   }


This My Controller
PHP Code:
function personal_inventory($id)
 
   {
 
       $employee_data["row"] = $this->Employee_model->view_data($id);
 
       $inventory_data["item"] = $this->Employee_model->view_inventory($id);
 
       //Total spends for current employee
 
       $inventory_data["total"] = $this->Employee_model->employee_spends($id);
 
       var_dump$inventory_data["total"]);
 
      // var_dump( $inventory_data);
 
       if ($inventory_data["item"]== null) {
 
           $this->load->view('includes/header');
 
           $this->load->view('includes/top_header');
 
           $this->load->view('includes/left_nav');
 
           $this->load->view('error_page/no_records'$employee_data);
 
           $this->load->view('includes/footer');
 
           $this->load->view('includes/settings');
 
       } else {
 
           $this->load->view('includes/header');
 
           $this->load->view('includes/top_header');
 
           $this->load->view('includes/left_nav');
 
           $this->load->view('employee/inventory'$inventory_data);
 
           $this->load->view('includes/footer');
 
           $this->load->view('includes/settings');
 
       }
 
   

This is my view
PHP Code:
<!-- Content WrapperContains page content -->
<
div class="content-wrapper">
 
   <!-- Content Header (Page header) -->
 
   <section class="content-header">
 
    <h2>Personal Inventory Area</h2>
 
   </section>
 
   <!-- Main content -->
 
   <section class="content">
 
       <div class="row">
 
           <div class="col-xs-12">
 
               <div style="margin-bottom: 10px;" >
 
                       <a href="<?= base_url() ?>employee/employee_list/" class="btn btn-info btn-lg">Back
                            to 
List</a>

 
               </div>
 
               <div class="box">
 
                   <div class="box-header">
 
                       <h3 class="box-title">Inventory Items</h3>
 
                   </div>
 
                   <!-- /.box-header -->
 
                   <div class="box-body">
 
                       <table id="example1" class="table table-bordered table-striped table-hover">
 
                           <thead>
 
                           <tr>
 
                               <th>Item Name</th>
 
                               <th>Price</th>
 
                               <th>Quantity</th>
 
                               <th>Serial Number</th>
 
                               <th>Product Key</th>

 
                           </tr>
 
                           </thead>
 
                           <tbody>
 
                           <?php
                            foreach 
($item as $row){
 
                               ?>
                                <tr>
                                    <td><?=$row["item_name"]?></td>
                                    <td class="text-left">Rs. <?=$row["price"]?>.00</td>
                                    <td><?=$row["qty"]?></td>
                                    <td><?=$row["serial_number"]?></td>
                                    <td><?=$row["product_key"]?></td>
                                </tr>
                                <?php
                            
}
 
                           ?>

                            </tbody>
                            <tfoot>
                            <tr>
                                <th>Item Name</th>
                                <th>Price</th>
                                <th>Quantity</th>
                                <th>Serial Number</th>
                                <th>Product Key</th>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                    <div>
                        <P>Total Spends is <?=$row->price?></P>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper --> 
Reply


Messages In This Thread
Cannot Pass More than two variable to view - by sanjaya - 04-21-2018, 10:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB