我正在尝试一次更新 11 行 - 之前从表单页面发布的板球队(11 名球员),然后我想更新与这些球员一起调用的第一个表。(表格包括球员、顺序和球队。)
<?php
session_start();
// Edit this to connect to your database with your username and password
$db_name="a1467234_cricket"; // Database name
$tbl_name="statistics"; // Table name
// Connect to server and select databse.
$conn = mysql_connect("mysql17.000webhost.com","*******","*******") or die(mysql_error());
mysql_select_db("$db_name")or die("cannot select DB");
$one = $_POST["one"];
$two = $_POST["two"];
$three = $_POST["three"];
$four = $_POST["four"];
$five = $_POST["five"];
$six = $_POST["six"];
$seven = $_POST["seven"];
$eight = $_POST["eight"];
$nine = $_POST["nine"];
$ten = $_POST["ten"];
$eleven = $_POST["eleven"];
$team = $_POST["team"];
$sql = "UPDATE first
SET player = (CASE
WHEN order = 1 ='$team' THEN '$one'
WHEN order = 2 AND team ='$team' THEN '$two'
WHEN order = 3 AND team ='$team' THEN '$three'
WHEN order = 4 AND team ='$team' THEN '$four'
WHEN order = 5 AND team ='$team' THEN '$five'
WHEN order = 6 AND team ='$team' THEN '$six'
WHEN order = 7 AND team ='$team' THEN '$seven'
WHEN order = 8 AND team ='$team' THEN '$eight'
WHEN order = 9 AND team ='$team' THEN '$nine'
WHEN order = 10 AND team ='$team' THEN '$ten'
WHEN order = 11 AND team ='$team' THEN '$eleven'
ELSE player
END
WHERE order IN (1,2,3,4,5,6,7,8,9,10,11))";
echo "Updated team selection";
mysql_close($conn);
?>
有谁知道如何让更新脚本工作?不会显示任何错误,它只是不会更改数据库。