Jump to content

CSV update


CameraTek

Recommended Posts

Hi all.

I'm currently using the code below to update my website with stock and pricing every day

 

 

 

while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {

$num = count($data);

echo "<p> $num fields to update in line $row: <br /></p>\n";

$row++;

for ($c=0; $c < $num; $c++) {

if ($c = 1) {

$supplier_reference = $data[($c - 1)];

echo $supplier_reference . " Supplier Reference Assigned <br />\n";

}

if ($c = 2) {

$reference = $data[($c - 1)];

mysql_query("UPDATE $update_table SET reference='$reference' WHERE supplier_reference='$supplier_reference'")

or die(mysql_error());

echo $reference . " Imported to product row <b>$row</b> in to MPN<br />\n";

}

 

The piece of code above only updates the current products.

When a product becomes unavailable (product becomes ops-elite) my suppliers remove it from the CSV file.

What I want is when an item is removed from the CSV, the code would set the product as unavailable for order, it would place a "0" in the available_for_order table.

 

Is this possible?

 

All help appreciated

 

Best Regards

Andy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...