Jump to content

[SOLVED] Math function within a query for output


elentz

Recommended Posts

I probably didn't put the subject quite right.  But, here is what I want to do.  I have a query that gets info from two tables and I show it on a page using Baagrid.  This works just fine.  Now I want to take it a step further.  In the query I have 3 fields, Qnty, Cost and Quote price.  What I want to do is somehow have the Cost multiplied by the Qnty to equal Ext Cost and to have Quote Price multiplied by the Qnty to equal the Extended Quote Price.  Then I want to put it into Baagrid so I can run a total. for both the extended cost and the extended quote price.  Is it possible to do this?  I would rather do this using a query rather that creating a new table or anything like that as I might be moving away from the current DB to another.

 

Here's my code:

//******************************************************
// Connection to the Database
//******************************************************

      $conn = mysql_connect("localhost", "admin", "xxxxxxxx");
      mysql_select_db ('mydb',$conn);

//******************************************************

$myvar=$_POST['mygetvar'];

//******Query to get the ticket information for the PDF*************
$sql =  "SELECT
vtiger_inventoryproductrel.quantity,
vtiger_products.productcode,
vtiger_products.mfr_part_no,
vtiger_products.productname,
vtiger_productcf.cf_450,
vtiger_inventoryproductrel.listprice
FROM
vtiger_inventoryproductrel
Inner Join vtiger_products ON vtiger_products.productid = vtiger_inventoryproductrel.productid
Inner Join vtiger_productcf ON vtiger_productcf.productid = vtiger_products.productid
WHERE
vtiger_inventoryproductrel.id =  '$myvar'";



//************End Query****************


include ('baaGrid.php');
$grid = new baaGrid ($sql);
$grid->setHeaderClass('head1');
$grid->showErrors(); // just in case
$grid->setHeadings("Qnty,Part#,Mfg Part #,Description,Our Cost,Quote Price");
$grid->setTotal(4,2);
$grid->setTotal(5,2);
$grid->display();

 

Thanks for looking!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.