0

Currently to check duplicates, the scripts checks fs the customer ID is existing in any of the rows and skips the record if it does. But however what I want to achieve is to check if the Customer ID exists and is mapped to the ProductIDs and append the unique product ID received via an HTML form post.

These customerIDs are imported into the DB via CSV sheet and the products are a checkbox which the user can select on the form where the csv file is uploaded, the values of the checkbox are posted as an array to the PHP script.

Table Name -> Customers There are 10 columns in the table, but the columns of interest to this question are 2.

  1. CustomerID
  2. ProductList
CustomerID  | ProductID
CUS123      | 1,2,3
CUS234      | 2,3,1
CUS345      | 2,4,5

So what i want to do is, browse the csv sheet and:

  1. Check the customerID, if it exists, check the productIDs its mapped against, match it with the list of productIDs received in the array and check for the unique product IDs it's now mapped against, and append the same to the row.

Mapping of the elements of the array received from the HTML form with the array items in the ProductID column of the table is the challenge here.

Strawberry
  • 33,750
  • 13
  • 40
  • 57
Vinay
  • 19
  • 1
  • 2
  • It may well be easier if you could normalise the database - storing multiple values in a single column never makes things easy. You really need a separate row for each product. – droopsnoot Aug 24 '20 at 13:30
  • 1
    @Strawberry Thank You for your recommendation, the moment I started to code the manipulation in PHP to query the Tables, I realised, this looks wrong. Read through the post link you shared... Will go ahead with your suggestion! Thank You much! :) – Vinay Aug 24 '20 at 15:59

0 Answers0