SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help w/function get and calc fields

    hello again

    I have a table that looks like this:


    I want to make the button recalculate the Sell and Hold price if the $cost or the $retail are changed

    I also have a table called "pricecodeprice" that contains factors for each type of PriceCode and ClientPriceCode
    e.g.
    [PRE]
    PriceCode ClientPriceCode RetailFactor SellFactor
    A1 R1 2 1.87
    A1 W1 1.2 1.2

    [/PRE]etc.

    I have attempted to write a function to handle this but I'm not there yet
    PHP Code:
    <?php
    function get_pprice($pid,$pc,$cost)
    {
      
    $ProductId $pid;
      
    $sql dbQuery("    
    SELECT PriceRetail, PriceSell, PriceHold, Cost, ClientPriceCode, ProductPriceId
    FROM productprice
    WHERE ProductId ='
    $ProductId'
        "
    );
        
    $row dbFetchAssoc($sql);
        if(
    $cost $row['Cost'])
        {
        
    mysql_data_seek($sql,0);
            while(
    $row dbFetchAssoc($sql))
          {
              
    $rows[] = $row;
          }

          return 
    $rows;
        }else
        {
        
    $sql dbQuery("
    SELECT RetailFactor, SellFactor
    FROM pricecodeprice
    WHERE PriceCode = '
    $pc'
      "
    );
            while(
    $row dbFetchAssoc($sql))
            {
            
    $rows[] =  $cost $row['RetailFactor']. $cost $row['SellFactor'];
            }
             
            return 
    $rows;
        
        }

    }
    Any Ideas??

    thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to make the button recalculate the Sell and Hold price if the $cost or the $retail are changed
    this can be done in javascript and php.

    for javascript use the below
    HTML Code:
    <script>
    recalculate() {
    // process
    }
    </script>
    
    
    <input type="text" value="value" onchange="javascript:recalculate()">

    for php i may be able to do it onchange but it will take some time, figure it out. or hire somebody.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •