search

Home  >  Q&A  >  body text

javascript - Questions about calculating the total price of different products

Now there are different products with different calculation formulas, such as product A, the calculation formula is: quantity X duration X unit price. Product B: unit price * quantity.
Please store the calculation formula and match it by yourself.

女神的闺蜜爱上我女神的闺蜜爱上我2799 days ago982

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-06-08 11:04:08

        $math = '%s*%s';
        $str  = sprintf($math, 5, 6);
        $result=eval("return $str;");
        var_dump($result);

    reply
    0
  • typecho

    typecho2017-06-08 11:04:08

    Give each product a flag directly, and then save the company in turn. When matching, you only need to match the flag to find the formula.

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-08 11:04:08

    Constructor, determines the execution content based on the parameters passed in

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-08 11:04:08

    select 商品A "商品名", 数量X时长X单价 "总计"
    from table
    where 商品=商品A
    union all
    select 商品B "商品名", 数量X单价 "总计"
    from table
    where 商品=商品B
    

    If it is product A

    select 商品B "商品名", 数量X单价 "总计"
    from table
    where 商品=商品B

    No result will be returned

    reply
    0
  • Cancelreply