
něco málo napřiklad http://itmax.podebrady.net/view.php?cisloclanku=2004123005





function CsvFile() {
global $db;
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
copy($_FILES['userfile']['tmp_name'], "tmp/product_list.csv");
$fp = fopen ("tmp/product_list.csv","r");
$fp1 = fopen("tmp/log.txt", "w");
while ($list = fgetcsv ($fp, 100000, ",")) {
$cid = intval($list[0]);
$title = stripslashes(FixQuotes($list[1]));
$image = $list[2];
$shortdescription = stripslashes(FixQuotes($list[3]));
$description = stripslashes(FixQuotes($list[4]));
$price = $list[5];
$weight = $list[6];
$featured = $list[7];
$option1 = $list[8];
$option2 = $list[9];
$option3 = $list[10];
$db->sql_query("insert into csv_products values(NULL, '$cid', '0', '$title', '$image', '$shortdescription', '$description', now(), '$price', '$weight', '$featured', '$option1', '$option2', '$option3', '0', '0', '0', '0')");
fwrite($fp1, $title."\n"); 
}
fclose ($fp1);
fclose ($fp);
unlink("tmp/product_list.csv");
Header("Location: admin.php?op=NECO");
}
}


)







$soubor="soubor.csv"
echo('<table>');
$fp = fopen ($soubor,"r");
while ($data = fgetcsv ($fp,1000, ";")) {
$num = count ($data);
echo('<tr>');
for ($c=0; $c<$num; $c++) {
echo('<td>' . $data[$c]. '</td>');
}
echo('</tr>');
}
echo('</table>');
fclose ($fp);





global $db;
$db->sql_query("LOAD DATA LOCAL INFILE 'c:/soubor.csv' INTO TABLE un_table FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' (name,city,..)");



$fp = fopen ("soubor.csv","r");
while ($data = fgetcsv ($fp, 100000, ",")) {
.. = $data[0];
$name = $data[1];
$name = iconv("CP1250", "ISO-8859-2", $name);
..
$db->sql_query("INSERT INTO un_table values(NULL, '$name','$city',...)");
}
fclose ($fp);


Obsah fóra BLASSENweb » Rady a porady - ostatní
|
|