All pastes #184686 Raw Edit

yavuz

public text v1 · immutable
#184686 ·published 2006-09-28 03:57 UTC
rendered paste body
<?php
header('Content-Type: text/html; charset=utf-8');
echo "<pre>";
require("lib/db.php");
$row = 1;
$aa = 0;
$handle = fopen("semsiye.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
   $num = count($data);
   //echo "<br /> $num fields in line $row: <br />\n";
   echo "<br>".$row."<br>";
   $row++;
   for ($c=0; $c < $num; $c++) {
	   $db[$c] = new db();
	   $db[$c]->db_connect();      
       $ex = explode(";",$data[$c]);
       
       //print_r($ex);
       $im = explode(".",$ex[$c]);
       //print_r($im);
       //echo $im["0"];
       $image[$c] = new db();
      // $image[$c]->insert_values("id",$imageid);
       $image[$c]->insert_values("image",$im["0"]);
       $image[$c]->insert_values("thum",$im["0"]);
       $image[$c]->insert_values("bigimage",$im["0"]);
       $sqlim = $image[$c]->sql_insert("image");
       echo "<br>".$sqlim."<br>";
       $qqq = $image[$c]->sql_query($sqlim);
       $imgid = mysql_insert_id();
       echo $imgid;
       $proid = $ex["0"];
       $name = $ex["1"];
       $comment = $ex["2"];
       $dimensions = $ex["3"];
       $packet = $ex["4"];
       $material = $ex["5"];
       $pressfields = $ex["6"];
       //$imageid = $ex["7"];
       $catid = $ex["8"];
       $delivery = "-";
       $price = "-";
       $date = "2006-09-27 23:04:00";
       $packet = iconv("ISO-8859-9", "UTF-8", $packet);
       $name = iconv("ISO-8859-9", "UTF-8", $name);
       $comment = iconv("ISO-8859-9", "UTF-8", $comment);
       $dimensions = iconv("ISO-8859-9", "UTF-8", $dimensions);
       $pressfields = iconv("ISO-8859-9", "UTF-8", $pressfields);
       $material = iconv("ISO-8859-9", "UTF-8", $material);
       $db[$c]->insert_values("productid",$proid);
       $db[$c]->insert_values("categoryid",$catid);
       $db[$c]->insert_values("name",$name);
       $db[$c]->insert_values("comment",$comment);
       $db[$c]->insert_values("dimensions",$dimensions);
       $db[$c]->insert_values("packet",$packet);
       $db[$c]->insert_values("material",$material);
       $db[$c]->insert_values("pressfields",$pressfields);
       $db[$c]->insert_values("imageid",$imgid);
       $db[$c]->insert_values("delivery",$delivery);
       $db[$c]->insert_values("price",$price);
       $db[$c]->insert_values("date",$date);
       $sql = $db[$c]->sql_insert("product");
       //echo $sql;
       $db[$c]->sql_query($sql);	
   }
}
fclose($handle);
//$db->db_close();
?>