Tanımsız işlev ProdTotal Çağrı ()

0 Cevap php

I ProdTotal toplam miktar sipariş ve bir ürün için sipariş toplam miktar almak ve Görüntü Fonksiyonu tabloda yüklemek işlevi çağırmak çalışıyorum. Ben hata alıyorum: tanımlanmamış işlev ProdTotal () çağır;

<?php 

Class CarsClass {
        private $user = 'php06'; 
        private $pwd = 'php06';  
        private $dbConn;

function __construct($db='classicmodels') {
        //Create connection to MySQL database requested, if blank just connect up.

        $this->dbConn = new mysqli('localhost', $this->user, $this->pwd, $db);
        if (mysqli_connect_errno()) {
            echo 'Error: Could not connect to database.  Please try again later.';
            exit;
         }
        $query = "select count(*) as 'custcount' from customers";

        $result = $this->dbConn->query($query);
        $row = $result->fetch_assoc();
        $custCount = $row['custcount'];

        print "Connected to DB $db as user $this->user<br><br> Number of Rows $custCount<br><br>";
    }

function __destruct(){
        mysqli_close();
        Print "DB closed by user <br><br>";
    }

function header(){
    echo "Midterm Exam Script 2 Header<br><br>";
    }

function display(){
    $totqty = 0;
    $totamt = 0;
    //get row from WB_Resident Table
    $query = "select productCode,productName,productDescription,quantityInStock,buyprice,MSRP from products";
    $result = $this->dbConn->query($query);
?>  

<table id="midterm2">

    <tr>
       <th colspan="13">Product Database Table</th>
    </tr>
    <tr> 
       <th width="2%">productCode</th>
       <th width="10%">productName</th>
       <th width="10%">productDescription</th>
       <th width="10%">quantity in stock</th>
       <th width="10%">buyPrice</th>
       <th width="2%">MSRP</th>
       <th width="10%">Total Qty Ordered</th>
       <th width="10%">Total $ Ordered</th>
    </tr>   

    <?php 
     while($row = $result->fetch_assoc()):
     $producta = $row["productCode"];
     ProdTotal($producta);

    ?>
    <tr>
      <td>
         <?php echo $row["productCode"]; ?>
         &nbsp;
      </td>
      <td>
        <?php echo $row["productName"];?>
        &nbsp;
        </td>
      <td>
         <?php echo $row["productDescription"]; ?>
         &nbsp;
      </td>
      <td>
         <?php echo $row["Qty In Stock"]; ?>
         &nbsp;
      </td>
      <td>
         <?php echo $row["Buy Price"]; ?>
         &nbsp;
      </td>
      <td>
         <?php echo $row["MSRP"]; ?>
         &nbsp;
      </td>
      <td>
         <?php echo $totqty; ?>
         &nbsp;
      </td>
      <td>
         <?php echo $totamt; ?>
         &nbsp;
      </td>

      </tr>
      <?php 
      endwhile;
      ?>
      </table>
    <?php   
  }

function footer(){
    echo "Midterm Exam Script 3 Footer<br><br>";
    }

function ProdTotal($product){

    echo "product code entered = $product <br><br>";
     $query = "select RTRIM(productCode) as productt, quantityOrdered, priceEach from orderdetails order by productt";

        $result = $this->dbConn->query($query);

        while($row = $result->fetch_assoc()){
        if ($row["productt"] == $product){
        echo $row;      
        $total = $row["quantityOrdered"] * $row["priceEach"];   
        $totqty = $totqty + $row["quantityOrdered"];
        $totamt = $totamt + $total;
        echo totqty;
        echo totamt;
        return array($totqty, $totamt);

        }
        }

        } 
        }    
    ?>

Bu komut dosyası, sınıf aramak için yürütülür.

<html>
<head>
<title>Midterm2 Script 3</title>
<link rel="stylesheet" type="text/css" href="midterm2.css" />
</head>

<body>

<?php 
require 'CarsClass3a.php';

$obj1= new CarsClass('classicmodels');

$obj1->header();
$obj1->display();
$obj1->footer();

?>

</body>
</html>

0 Cevap