Hello all,

I am trying to write a function or functions to recalculate two price fields for multiple clients.

My price fields are:

which I want to control based on a $Cost variable (also a field I will save) and a $PriceCode variable that references a table that stores the factors for the two price fields to be changed/recalculated

this involves 2 db tables (productprice, pricecodeprice)

here is what I have so far -
PHP Code:

# For recalculating product prices.
if ($_GET['ProductId'] && $_GET['Cost'] && $_GET['PriceCode']) {

$ProductId $_GET['ProductId'];
$Cost             $_GET['Cost'];
$PriceCode $_GET['PriceCode'];

//grab all the client types to recalculate prices for.
$q dbQuery("SELECT ClientPriceCode FROM productprice WHERE ProductId ='$ProductId'");
$nClients dbNumRows($q);

$row dbFetchAssoc($q))
$CPC_list[] = $row['ClientPriceCode'];

// get the factors for each client type from pricecodeprice.
$q dbQuery("SELECT RetailFactor, SellFactor FROM pricecodeprice WHERE ClientPriceCode IN('".join("', '"$CPC_list)."')"); 
$row dbFetchAssoc($q);
I'm having trouble setting up my queries to do the math I need to and then display them in an HTML table.

Any Ideas??