elentz Posted July 23, 2008 Share Posted July 23, 2008 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! Quote Link to comment Share on other sites More sharing options...
accident Posted July 23, 2008 Share Posted July 23, 2008 in the SELECT query part add this quantity * cost AS ext_cost, quote_price * quantity as ext_quote as 2 columns Quote Link to comment Share on other sites More sharing options...
elentz Posted July 23, 2008 Author Share Posted July 23, 2008 I never knew you could do that! But I was hoping! That works perfectly! Thank you very much!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.