dongyue1988 2017-02-04 07:45
浏览 31

在数据库中保存'if condition statement'并以php格式使用它

I have a table named user where I have inserted a value like

($workshop_sales*0.01)+($counter_sales*0.005)+($sub_dealer_sales*0.0075)

in column incentive and value like

if{$workshop_sales>1600000' in column 'open_cond' and value like '}

in close_cond.

Now in my PHP page I have fetched values from that table. How can I use values from my columns open_cond and close_cond because I wish to use it as expression otherwise please help me by giving other way to execute it.I am doing wrong then please give me information whether its possible that I can write 'if statement' in php using it store as a text value in database column value ?? ''

I am getting result as

if($workshop_sales>1600000){2123.085}

but I want to use it as PHP expression in my code.

<?php
      $selectalldepartment = "select * from user ";
                                                                                                                                                                           $selectedalldepartment = mysqli_query($conn,$selectalldepartment);
    $selectedalldepartment = mysqli_query($conn,$selectalldepartment);                                                               
    $depart=1;
    while($row10 = mysqli_fetch_assoc($selectedalldepartment))
    {
        $sqlsel1 = "select * from parameters ";
        $sqlsel1q = mysqli_query($conn,$sqlsel1);
        $row2 = mysqli_fetch_assoc($sqlsel1q);
        //assigned counter sales value
        $counter_sales  = $row2["counter_sales"];
        ?>
        <tr>
            <td style="text-align:center;"><?php echo $depart; ?></td>
            <td style="text-align:center;"><?php echo $row10["open_condition"]; eval("echo {$row10['incentive']};");echo $row10["close_condition"];?></td>        </tr>
        <?php
        $depaz++;
        $depart++;
    }
    ?>

Here is my table:

<!-- language: lang-none -->

user_id  |  user_name  |  incentive                 |open_cond           |   close_cond                                                                |
     1   | Goldy Shahu | ($workshop_sales*0.01)+    |                    |
         |             |   ($counter_sales*0.005)+  |                    |
         |             |  ($sub_dealer_sales*0.0075)|if($workshop_sales> |
                                                       1600000){         |}
  • 写回答

1条回答 默认 最新

  • douzhengzuo7283 2017-02-04 07:56
    关注

    you should not store conditions into your table need to store data like

    $workshop_sales and 1600000 in seporate columns

    then you can make condition

    like something

    if($row10["open_condition"] > $row10["open_condition_value"]){
    //your code 
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line