php - Modify database value if a different vaule matches a CSV file -


ok, new here , if question has been answered, please direct me, cannot find it.

i have database products in it. receive list of product codes supplier in csv format. has 1 column. want take list of product codes , compare list of codes in database. if product code on list in csv, want modify stock status value product in database. basically,

if "item_a" exists, change "value_b".

i hope have been clear enough correct answer...

thank in advance.

p.s. this>>php mysql import csv , compare , remove redundant entries seems in right direction, instead of deleting, want change different value

store csv data in array use this:-

foreach($csvid $productid){ $productid = mysql_real_escape_string($productid); $res = mysql_query('select count(*) products product_id = ' .$productid) or die(); $row = mysql_fetch_row($res); if ($row[0] > 0) {     //productexists $updated_result = mysql_query('update products set product.item_a="value_b" product_id = ' .$productid) or die();     } else {     //it doesn't } } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -