I am trying to create a PHP function where I can upload one CSV file into MySQL and then export another CSV file with certain changes in data and tables.
Example
CSV-1:
Table name = Photolink
Table content = http:// www.sitename.com/image1.jpg
Convert it to:
CSV-2:
Table name = img_URL
Table content = product/image1.jpg
I need your help in modifying the code to make this work;
I tried this code still it do not work, friends can u help me fix it please!
$data1 = $mysql->prepare("INSERT INTO products (name, model, quantity, image_url) VALUES (:name, :model, :quantity, :image_url)");
$data1->bindParam(':name', $name);
$data1->bindParam(':model', $model);
$data1->bindParam(':quantity', $quantity);
$data1->bindParam(':image_url', $image_url);
if ($_FILES[csv][size] > 0) {
//get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
while ($data = fgetcsv($handle,1000,",","'")) {
if ($data[0]) {
$name = $data[0];
$model = $data[1];
$quantity = 100;
$image_url = $data[2];
$data1->execute();
}
}