Guest User

Untitled

a guest
Jul 18th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?
  2. // Configuration
  3. $DBHOST = "host"; //mysql host name
  4. $DBUSER = "user"; //database username
  5. $DBPASS = "pass"; //database password
  6. $DBNAME = "db"; //database name
  7.  
  8. $database = fopen('text.csv', 'r+');
  9. $headers = fgetcsv($database);
  10. $unique = array();
  11. $queries = array();
  12.  
  13. while( ($data = fgetcsv($database) ) !== FALSE ) {
  14. if( !in_array($data[0], $unique) ) {
  15. $queries[] = "UPDATE Product SET Custom1Ind = 1, Custom1Title = '" . $data[1] . "', Custom2Ind = 1, Custom2Title = '" . $data[2] . "' WHERE SKU = '" . $data[0] . "' AND StoreID = 24";
  16. $unique[] = $data[0];
  17. }
  18. }
  19. fclose($database);
  20. foreach( $queries as $query ) {
  21. //mysql_query( $query );
  22. echo $query."<br>";
  23. }
  24. ?>
Add Comment
Please, Sign In to add comment