我遇到的问题是它不会更新我的数据库。我无法检测到问题,甚至没有出错。以下是我的代码。
<?php
$db=mysqli_connect('localhost','','','') or die(mysql_error());
$bookId = $_POST['bookId'];
$amount = $_GET['amount'];
$userName = $_SESSION['user'];
$name = $_GET['name'];
$sql = "SELECT * FROM booking JOIN product ON (product.name = booking.name) JOIN users ON (users.userName = booking.userName)";
$resultcount = mysql_query($sql) or die("MySQL error: " . mysql_error());
if ($resultcount > 0) {
mysql_query("UPDATE booking SET amount = '$amount', userName = '" . $_SESSION['user'] . "', name = '$name' WHERE bookId = '$bookId'")
or die(mysql_error());
} else {
mysql_query("INSERT INTO booking (bookId, amount, userName, name) VALUES ('$bookId', '$amount', '$userName', '$name')")
or die(mysql_error());
}
echo "<table border='1' align='center' style='width:800px'>";
echo "<tr style='background-color:#d8c7ad;' align='center'><th style='width:100px'>Booking ID</th><th style='width:100px'>User Name</th><th style='width:100px'>Bike Name</th><th style='width:50px'>Amount</th></tr>";
while($x = mysql_fetch_array($resultcount))
{
echo "<tr><td>$x[bookId]</td><td>$x[userName]</td><td>$x[name]</td><td>$x[amount]</td></tr>";
}
echo "</table><br>";
?>