I have a table of the structure of the following type. The url data seems to be fine. The bay values (B1 B2 B3) are set to 1 of integer kind.
DateToBook | B1 | B2 | B3 |
------------------------------------
8March2013 | 1 | 1 | 1 |
I couldn't get the values inserted. The baycount for the above structure is 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);
?>
Is there anything that is wrong with the syntax?