好吧,我想做的是,让这个按钮插入时,运行buy\u item.php,我的tottality lost,我想让脚本检查金额(钱包钱)的用户和检查价格的点击按钮的项目(每个项目是相关的购买按钮),如果他们有足够的钱它买。但是scrript不起作用,按钮更新了
<?php
$conn = mysqli_connect("localhost", "localhost", "localhost", "localhost");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id,type, price,seller FROM items
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo '<td><form action="buy_item.php"><button>a</button></form></td>';
echo "</tr>";
}
echo "</table>";
} else { echo "0 results"; }
$conn->close();
?>
</table>
购买物品.php
<?php
session_start();
$conn = mysqli_connect("localhost", "localhost", "localhost", "localhost");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT price,username,amount FROM items,users WHERE username = '" .
$_SESSION['username'] . "' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
if $row["amount"] >= $row["price"] {
$newAmount = $row["amount"] - $row["price"] ;
header("location:/quickshops/seller/tutoadd.php");
}
else
{
echo "You got no enough money buddy.";
}
}
暂无答案!
目前还没有任何答案,快来回答吧!