php、mysqlでmaster2に。私はPHPで約2ヶ月間新しいです
私は助けが必要です。更新テーブルについて。
現在のテーブルを表示するページがあります。更新ボタンの更新をクリックすると、行1が必要になります。現在のテーブルの数量は、結果テーブルからIdItemだけ減少します。したがって、方程式は現在のテーブルquantity=quantity-quantityPassでこのようになります。したがって、項目品目変更数量結果のみが表示されます。これで、[更新]をクリックすると、テーブルの現在の結果のすべてに影響します。解決策はありますか?
'結果'のテーブル
+--------+-------------+--------------+-----------+--------+--------------+
| IdItem | username | rentItem | quantity | result | quantityPass |
+--------+-------------+--------------+-----------+--------+--------------+
| 84 | FahmiNazirul| Speaker | 1 | PASS | 1 |
+--------+-------------+--------------+-----------+--------+--------------+
| 86 | Andy | Keyboard | 3 | PASS | 2 |
+--------+-------------+--------------+-----------+--------+--------------+
| 89 | FahmiNazirul| Speaker | 5 | PASS | 3 |
+--------+-------------+--------------+-----------+--------+--------------+
現在の数量のテーブル'更新'
+--------+-------------+--------------+
| Id | Item | quantity |
+--------+-------------+--------------+
| 1 | Speaker | 10 |
+--------+-------------+--------------+
| 2 | Keyboard | 10 |
+--------+-------------+--------------+
tableupdate.php
$result = mysql_query("SELECT * FROM update where Item = Item");
echo "<table border='1'>
<tr>
<th>Item</th>
<th>Quantiti</th>
<th></th>
</tr>";
while($row = mysql_fetch_array($result))
{
$item= $row['Item'];
echo " <tr> ";
echo " <td> " . $row['Item'] . " </td> ";
echo " <td> " . $row['quantity'] . " </td> ";
echo " </tr> ";
}
echo "</table>";
echo " <a href ='quantityupdate.php?Item=$item' onclick='return Confirm_Box()' >Update</a>";
amountupdate.php
$item =$_REQUEST['Item'];
// sending query
mysql_query("UPDATE update ,result SET update.quantity=update.quantity-result.quantityPass where update.Item = result.rentItem")
or die(mysql_error());
header("Location: update.php");