我的 PHP 代码
<?php include 'config.php';
if(isset($_POST['submitbtn'])){
$date = $_POST['datefield'];
$newDate = date("Y-m-d", strtotime($date));
$result = mysql_query("Call seat(".$newDate.")");
if($result == FALSE){
echo "Sorry Query Failed!";
}
else
{
echo "Success";
}
}
?>
html>
<head>
</head>
<body>
<form method="post">
<input type="date" name="datefield"><br>
<input type="submit" name="submitbtn">
</form>
</body>
</html>
这将调用具有定义的存储过程:
CREATE DEFINER=`root`@`localhost` PROCEDURE `seat`(IN `dateP` VARCHAR(20))
NO SQL
begin
declare i int default 1;
while i < 250 do
insert into seat (Seat_ID,dateP) values (i,dateP);
set i = i + 1;
end while;
end
桌椅结构如下:
CREATE TABLE IF NOT EXISTS `seat` (
`ID` int(100) NOT NULL AUTO_INCREMENT,
`Seat_ID` int(4) NOT NULL,
`Row_ID` varchar(2) NOT NULL,
`Col_ID` int(4) NOT NULL,
`Amount` int(3) NOT NULL,
`DateP` date NOT NULL,
PRIMARY KEY (`ID`)
)
这里 DateP 列作为 0000-00-00 插入到所有 250 行中。请帮助我哪里出错了。