|
|
|
import text file แล้ว update ข้อมูลที่ละหลายบรรทัดทำไงค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & Text To MySQL</title>
</head>
<body>
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); // Conect to MySQL
$objDB = mysql_select_db("mydatabase");
$strFileName = "thaicreate.txt";
$objFopen = fopen($strFileName, 'r');
if ($objFopen) {
while (!feof($objFopen)) {
$file = fgets($objFopen, 4096);
$strSQL = "INSERT INTO customer ";
$strSQL .="(Name) ";
$strSQL .="VALUES ";
$strSQL .="('".$file."') ";
$objQuery = mysql_query($strSQL);
}
fclose($objFopen);
}
echo "Import Done.";
?>
</table>
</body>
</html>
|
|
|
|
|
Date :
2013-07-10 06:15:01 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าต้องการให้ update ยังไงดีค่ะ
|
|
|
|
|
Date :
2013-07-10 06:24:22 |
By :
testone |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เปลี่ยนจาก Insert เป็น Update ครับ
Code (PHP)
<?php
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); // Conect to MySQL
$objDB = mysql_select_db("mydatabase");
$strFileName = "thaicreate.txt";
$objFopen = fopen($strFileName, 'r');
if ($objFopen) {
while (!feof($objFopen)) {
$file = fgets($objFopen, 4096);
$strSQL = "UPDATE customer SET ..... WHERE ....";
$objQuery = mysql_query($strSQL);
}
fclose($objFopen);
}
echo "Import Done.";
?>
|
|
|
|
|
Date :
2013-07-10 08:17:30 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|