我正在创建一个应用程序,其中要上传CSV文件并在HTML表中显示数据。现在我想知道如何基于该HTML表创建MySQL表?
我知道直接创建CSV到MySQL表。
但是我需要执行一些操作,例如从表中隐藏一些列,并基于该表创建MySQL表。这是到目前为止我所做的。 我的HTML代码
<script>
$(document).ready(function () {
$.ajax({
url: "/PO/testfile.csv",
dataType: "text",
success: function (data) {
var employee_data = data.split(/\r?\n|\r/);
var table_data = '<table class="table table-bordered table-striped">';
for (var count = 0; count < employee_data.length; count++) {
var cell_data = employee_data[count].split(",");
table_data += '<tr>';
for (var cell_count = 0; cell_count < cell_data.length; cell_count++) {
if (count === 0) {
table_data += '<th>' + cell_data[cell_count] + '</th>';
} else {
table_data += '<td>' + cell_data[cell_count] + '</td>';
}
}
table_data += '</tr>';
}
table_data += '</table>';
$('#employee_table').html(table_data);
}
});
});
</script>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"/>
</head>
<body>
<div class="container">
<div class="table-responsive">
<br />
<br />
<div id="employee_table">
</div>
</div>
</div>
</body>
</html>