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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.