Jump to content

How replace data csv to mysql


cerom

Recommended Posts

need help ... How  replace csv  to mysql ...

 

 


<html>
<head>
<title>Replace</title>
</head>
<body>
<?
copy($_FILES["fileCSV"]["tmp_name"],"shotdev/".$_FILES["fileCSV"]["name"]); // Copy/Upload CSV


$objConnect = mysql_connect("localhost","root","root") or die(mysql_error()); // Conect to MySQL
$objDB = mysql_select_db("mydatabase");


$objCSV = fopen("shotdev/".$_FILES["fileCSV"]["name"], "r");
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
$strSQL = "INSERT INTO customer ";
$strSQL .="(CustomerID,Name,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$objArr[0]."','".$objArr[1]."','".$objArr[2]."' ";
$strSQL .=",'".$objArr[3]."','".$objArr[4]."','".$objArr[5]."') ";
$objQuery = mysql_query($strSQL);
}
fclose($objCSV);


echo "Import completed.";
?>
</body>
</html>
 

 

Link to comment
https://forums.phpfreaks.com/topic/276248-how-replace-data-csv-to-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.