get value from table and interpoation

Discussion in 'PHP' started by arctushar, Oct 20, 2008.

  1. #1
    ---------------|--------------hosting Space------------------|
    QUANTITY------1 GB----------------3 GB ----------------10 GB
    ---10------------$50----------------$60------------------$70
    ---20------------$80---------------$100-----------------$120
    ---30------------$90---------------$130-----------------$150

    The above table is given to server database ( in sql )
    User will input hosting space and quantity
    when he submit web page will give him/her the price.

    Example-- ( by red color value)

    1. User will input in quantity field---20
    2. User will input in Space field ----3
    3. User will click in submit button
    the result shown in screen that " ur price is $100"

    Please give me detail how can I do that.

    another for advance mode

    Now I need also another answer.
    User can customize their offer . If user want hosting space of 10GB and a quantity of 23 then what will be the price.
    Procudure is.

    Price= $120+ [($150-$120)/(30-20)]*(23-20)= $129
    So the result will be $129 whe user input 23 in quantity field and 10 in space field
     
    arctushar, Oct 20, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    I dont understand exactly what you mean? what for table? please give more details! :)
     
    EricBruggema, Oct 20, 2008 IP
  3. arctushar

    arctushar Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Please help me
     
    arctushar, Oct 22, 2008 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    do you use a class for array convertion of you query?
    if not convert first your table into php array (it will lessen the work load of the server)

    sample
    $sampleArray = array();
    while($aaa = mysql_fetch_array($bbb))
    {
    array_push($sampleArray,$aaa);
    }
    echo "<pre>";
    print_r($sampleArray);
    echo "</pre>";

    at this point it will be your logic to do your equations..
    in your table example it will be 2 to 3 dimensional array, doing a double for loop for this..
     
    bartolay13, Oct 22, 2008 IP
  5. arctushar

    arctushar Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello
    Thank u for giving me solution. Can u plz give me detail coding with php code.
    I m a new user
     
    arctushar, Oct 23, 2008 IP
  6. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #6
    ok did you already convert it into php array?
    echo "<pre>";
    print_r($sampleArray);
    echo "</pre>";
     
    bartolay13, Oct 23, 2008 IP