使用php在两个不同的表中匹配数字

时间:2017-01-31 16:44:48

标签: php mysqli

我有一个表单,提交数字到数据库,也有50%的多个数字。但我想循环并匹配数据库中的数字动态。例如,哪里是40,000.00它将匹配到6万已经在数据库中下面是我的代码,插入数据库和50%的倍数

<?php
session_start(); {

    //Include database connection details
    include('../../dbconnect.php');

$amount =  strip_tags($_POST['someid']);
$field1amount = $_POST['cat'];
$field2amount = $field1amount + ($field1amount*0.5);

    $sql = "INSERT INTO transactions (amount,topay)
                   VALUES ('$field1amount','$field2amount')";

if (mysqli_query($conn, $sql)) 

 {
    $_SESSION['ph'] ="<center><div class='alert alert-success' role='alert'>Request Accepted.</div></center>";
   header("location: PH.php");
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
}
?>

以下是html表单

    <label>Select amount to payout</label>
    <form action="phaction.php" method="post">
    <div class="form-group">

<select class="form-control" id="cat" name="cat">
  <option value="20,000.00">20,000.00(Twenty Thousand naira)</option>

<option value="40,000.00">40,000.00(Forty Thousand naira)</option>
 <option value="100,000.00">100,000.00(Hundred Thousand naira)</option> 
 </select>
  </div>

        <div class="box-footer clearfix">
        <button class="pull-right btn btn-default" id="sendEmail">Update <i class="fa fa-arrow-circle-right"></i></button>
        </div>
    </form>
    </div>

那么请如何将数字与数据库中50%的数字相匹配,例如40到60,依此类推。请任何可以帮助mysql查询的人?

0 个答案:

没有答案