我有一个以下类型的结构表。网址数据似乎很好。间隔值 (B1 B2 B3) 设置为整数类型的 1。
DateToBook | B1 | B2 | B3 |
------------------------------------
8March2013 | 1 | 1 | 1 |
我无法插入值。上述结构的baycount是3。
<?php
$DB_hostname = "localhost";
$DB_Name = "root";
$DB_pass = "pass123";
if(isset($_GET["tabName"])){
$tableName = $_GET["tabName"];
$dB = $_GET["db"];
$bayCount = $_GET["bayNo"];
$date = $_GET["d"];
$b = '1';
}
$con = mysql_connect($DB_Hostname,$DB_Name,$DB_pass) or die(mysql_error());
mysql_select_db($db, $con);
$_bayColumn = array();
for ($i = 1; $i <= $bayCount; $i++) {
$_bayColumn[] = "B$i";
}
echo $_bayColumn[0];
mysql_query("INSERT INTO $tableName (DateToBook) VALUES ($date)");
for ($j =0; $j < $bayCount; $j++) {
mysql_query("UPDATE $tableName SET $_bayColumn[$j] = '$b' WHERE DateToBook = '$date'");
}
mysql_close($con);
?>
语法有什么问题吗?