|
|
|
เอาฟังก์ชั่นดีๆมาแจก ฟังก์ชั่นลบโฟเดอร์และไฟล์ที |
|
|
|
|
|
|
|
อะฟังก์ชั่น import file sql
function import($sqlfile) {
$file = fopen($sqlfile, 'r');
$data = array();
$i = 0;
$data[0]='';
while($line = fgets($file))
{
$line = ereg_replace("\r\n$", '', $line);
$line = ereg_replace("\r$", '', $line);
$line = ereg_replace("\n$", '', $line);
trim($line);
if (!ereg('^--|^#', $line) && $line != '') {
$data[$i] .= ' ' . $line;
if (ereg(';$', $line)) {
$i++;
$data[$i]='';
}
}
}
foreach ($data as $i => $query) {
if ($query != '') {
mysql_query($query); // ใช้คำสั่ง
}
}
}
//เรียกใช้
$sql = 'CREATE TABLE IF NOT EXISTS `account` (
`id` bigint(20) NOT NULL auto_increment,
`memid` varchar(11) collate utf8_unicode_ci NOT NULL,
`acct_no` varchar(20) collate utf8_unicode_ci NOT NULL,
`acct_type` varchar(40) collate utf8_unicode_ci NOT NULL,
`acct_name` varchar(50) collate utf8_unicode_ci NOT NULL,
`bnk_name` varchar(50) collate utf8_unicode_ci NOT NULL,
`branch` varchar(80) collate utf8_unicode_ci NOT NULL,
`address` varchar(100) collate utf8_unicode_ci NOT NULL,
`city` varchar(50) collate utf8_unicode_ci NOT NULL,
`state` varchar(50) collate utf8_unicode_ci NOT NULL,
`country` varchar(2) collate utf8_unicode_ci NOT NULL,
`postcode` varchar(10) collate utf8_unicode_ci NOT NULL,
`phone` varchar(20) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;
--
-- Dumping data for table `account`
--
INSERT INTO `account` (`id`, `memid`, `acct_no`, `acct_type`, `acct_name`, `bnk_name`, `branch`, `address`, `city`, `state`, `country`, `postcode`, `phone`) VALUES
(1, '1182237509', '5151515151', 'Checking', 'phichete', 'BBl', 'Cm Airport', 'T. Haiya', 'Muang', 'CM', 'TH', '50000', '0532010102');';
import($sql);
***********************************************
จะลองปรับ เป็นทำฟอร์ม <input type="file" ....> ก็ได้นะ
ใครเอาไปใช้ได้ผลไงมั่งก็บอกเน่อ
|
|
|
|
|
Date :
7 ม.ค. 2551 10:39:22 |
By :
xboy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กำลังมองหาจริงๆ ขี้เกียจคิด
ขอบพระคุณมากค่ะ
|
|
|
|
|
Date :
7 ม.ค. 2551 10:40:25 |
By :
บิ้ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|