|
|
|
จะอัพไฟล CVS ขึ้นไปบน MYSQL แต่ตอดอะครับทำต่อไมได้ มือใหม่ครับ |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & CSV To MySQL</title>
</head>
<body>
<?
copy($_FILES["fileCSV"]["tmp_name"],$_FILES["fileCSV"]["name"]); // Copy/Upload CSV
$objConnect = mysql_connect("localhost","root","topgun") or die("Error Connect to Database"); // Conect to MySQL
$objDB = mysql_select_db("PHP387");
$objCSV = fopen("product.csv", "r");
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
$strSQL = "INSERT INTO product ";
$strSQL .="(p_id,prefill,p_barcode,b_name,auther,edition,year,p_detail,p_price,p_img,c_id,weight) ";
$strSQL .="VALUES ";
$strSQL .="('".$objArr[0]."','".$objArr[1]."','".$objArr[2]."' ";
$strSQL .=",'".$objArr[3]."','".$objArr[4]."','".$objArr[5]."',";
$strSQL .=",'".$objArr[6]."','".$objArr[7]."','".$objArr[8]."',";
$strSQL .=",'".$objArr[9]."','".$objArr[10]."','".$objArr[11]."',";
$objQuery = mysql_query($strSQL);
}
fclose($objCSV);
?>
</table>
</body>
</html>
งงเลยครับ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-10-13 15:05:20 |
By :
phpbegins |
View :
919 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
Code (PHP)
[php]<html>
<head>
<title>ThaiCreate.Com PHP & CSV To MySQL</title>
</head>
<body>
<?
copy($_FILES["fileCSV"]["tmp_name"],$_FILES["fileCSV"]["name"]); // Copy/Upload CSV
$objConnect = mysql_connect("localhost","root","topgun") or die("Error Connect to Database"); // Conect to MySQL
$objDB = mysql_select_db("PHP387");
$objCSV = fopen("product.csv", "r");
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
$strSQL = "INSERT INTO product ";
$strSQL .="(p_id,prefill,p_barcode,b_name,auther,edition,year,p_detail,p_price,p_img,c_id,weight) ";
$strSQL .="VALUES ";
$strSQL .="('".$objArr[0]."','".$objArr[1]."','".$objArr[2]."' ";
$strSQL .=",'".$objArr[3]."','".$objArr[4]."','".$objArr[5]."' ";
$strSQL .=",'".$objArr[6]."','".$objArr[7]."','".$objArr[8]."' ";
$strSQL .=",'".$objArr[9]."','".$objArr[10]."','".$objArr[11]."')";
$objQuery = mysql_query($strSQL);
}
fclose($objCSV);
?>
</table>
</body>
</html>
[/php]
|
|
|
|
|
Date :
2009-10-13 15:13:49 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อธิบายทีครับ ผมงงมาก
|
|
|
|
|
Date :
2009-10-13 15:30:33 |
By :
phpbegins |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลืมเครื่องหมาย ) นะครับ
อันนี้ของคุณ ~AE_FREE_HAND~ นะครับ
Code (PHP)
$strSQL .=",'".$objArr[9]."','".$objArr[10]."','".$objArr[11]."',";
อันนี้ของคุณวิน
Code (PHP)
$strSQL .=",'".$objArr[9]."','".$objArr[10]."','".$objArr[11]."')";
|
|
|
|
|
Date :
2009-10-13 15:46:23 |
By :
zepherus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|