亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

根據另一個數字增加一個數字

根據另一個數字增加一個數字

PHP
嚕嚕噠 2022-10-22 16:19:14
我正在嘗試找到一種方法來增加我的數據庫中的一個數字,我根據另一個從設備自動更新的數字手動輸入該數字。在我的數據庫中,我有幾列,但重要的是 cancelled_meter mec_in demult.``cancelled_meter`` 是自動更新的列``mec_in`` 是手動輸入的列``demult`` 也是自動更新的列這些列都是數字(例如cancelled_meter= 428080.00、mec_in= 2174827.00,demult通常是 1、100 或 1000。這是我在 PHP 中嘗試做的事情:    <?php    $sql = "SELECT id, cancelled_meter, total_drop, mec_in, mec_out, demult, val_pct             FROM machtest ORDER BY id DESC LIMIT 1";    $result = $conn->query($sql);if ($result->num_rows > 0) {    echo "<table><tr><th>ID</th>                     <th>Coin IN Meter</th>                     <th>Coin OUT Meter</th>                     <th>Demultiplication</th>                     <th>Pt Value</th>                     <th>Total IN</th>                     <th>Total OUT</th>                  </tr>";    while($row = $result->fetch_assoc()) {          $offset_in = $row["cancelled_meter"] - $row["mec_in"] * -1;        $abbs_in = abs($offset_in);        $round_in = abs($row["cancelled_meter"] / $row["demult"] + $abbs_in);                        $offset_out = $row["total_drop"] - $row["mec_out"] * -1;        $abbs_out = abs($offset_out);        $round_out = abs($row["total_drop"] / $row["demult"] + $abbs_out);                echo "<tr>                <td>"                    .$row["id"]."</td>".                "<td>"                    .$row["cancelled_meter"]."</td>".                "<td>"                    .$row["total_drop"]."</td>".                "<td>"                    .$row["demult"]."</td>".                "<td>"                    .$row["val_pct"]."</td>".                "<td>"                    .$round_in."</td>".                "<td>"                    .round($row["total_drop"] / $row["demult"] + $abbs_out)."</td>              <tr>";    }這種工作,但我想顯示更改mec_in時自動更新哪些cancelled_meter只顯示其他內容。還有一件事是,它mec_in可以更大或更小 cancelled_meter,這就是為什么我需要一個積極的結果。我正在嘗試像mec_in= cancelled_meter/ demult+ 一些介于cancelled_meter和之間的偏移量mec_in。我試圖弄清楚這一點,但我是初學者,所以如果有人有一些建議,我將非常感激。PS。我試圖在 php 文件上計算這個,但如果有人知道如何,在 MySQL 中也很好。
查看完整描述

1 回答

?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

我不知道我腦子里想的是什么,但添加后$total = abs($round_in - $row["offset_in"]);效果很好。我offset_in通過做得到了專欄$round_inmec_in然后$round_in - $row["offset_in"]);給出了預期的結果。謝謝您的意見。



查看完整回答
反對 回復 2022-10-22
  • 1 回答
  • 0 關注
  • 142 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號