Jump to content

retrieve data from table with multiple returned variable


samoht

Recommended Posts

hello,

 

I am trying to set up a function to recalculate prices for my products - (per product that is)

 

The problem I am having is that I have a table that stores the prices for each client type (so one product can have multiple prices) so I need to be able to recalculate the price for each client.

 

Here is my db set up:

 

tables:

productprice

ProductPriceId pk

ProductId fk to product

ClientPriceCode

PriceRetail

PriceSell

Cost

 

pricecodeprice

pcpId pk

PriceCodeId fk to pricecode

ClientPriceCode

RetailFactor

SellFactor

CostFactor (not neccesary)

 

When I come into my function I pass the values of ProductId, PriceCodeId, and Cost. Based on these three known variables I then

 

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

now I need to get the factors from pricecodeprice - but I will have multiple clients

so how do I get the factors from the pricecodeprice table??

<?php
// get the factors for each client type from pricecodeprice.
$q = dbQuery("SELECT RetailFactor FROM pricecodeprice WHERE ??"); 

 

perhaps I should use a for loop?

for(i=0; i<$nClients; i++) {

then grab the factors inside the loop. But how do I store the factors to be able to do the math on them?

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.