我不希望逐个放入数据,如何一次放入大量数据? 我在Excel中的数据。想要改成数据库(我的sql)
答案 0 :(得分:0)
如果你指的是从excel迁移到mysql,有很多像https://www.webyog.com/product/downloads/ 如果它只是加载您可以使用的数据,请通过此http://dev.mysql.com/doc/refman/5.1/en/load-data.html
答案 1 :(得分:0)
convert your excel to csv and upload using following script
<?php
include 'connection.php';
if(isset($_POST['Submit']))
{
if ($_FILES['csv']['size'] > 0)
{
//get the csv file
$file = $_FILES['csv']['tmp_name'];
$handle = fopen($file,"r");
while ($data = fgetcsv($handle,1000,","))
{
mysql_query("INSERT INTO tablename (col1, col2,col3) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."'
)
") or die(mysql_error());
header('Location: home.php');
}
}
}
?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
Choose your file:<input name="csv" type="file" id="csv" />
<input type="submit" name="Submit" value="Submit" />
</form>