我有以下代码,它正确地将数据插入到mysql数据库中,但是当我上传文件时,该特定文件将永远不会包含mysql表中存在的某个名为“date”的列。我想把它放在每一行......所以基本上,我怎么把最后一列变成$ dadate?
以下是代码:
<?php
require_once('header2.php');
require_once('access.php');
?>
<head>
<title>Upload</title>
</head>
<body>
<?php
$filedir = addslashes($_FILES['file']['tmp_name']);
$dadate = $_POST['datadate'];
echo $dadate;
if (isset($_POST['submit'])) {
$sql="LOAD DATA LOCAL INFILE '$filedir' INTO TABLE employeehourstest FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 18 LINES (@dummy, @dummy, @dummy, @dummy, employeeid, @dummy, @dummy, paycode, @dummy, @dummy, @dummy, employeehours, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy)";
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
if ($result) {
echo "<h1>" . "File ". $_FILES['file']['name'] ." uploaded
successfully." . "</h1>";
}
}
?>
</body>
</html>
以下是我的表格如何使用此代码上传:
以下是显示$ dadate的php上传结果: