You mean why are there duplicates in the database in the first place?
The database is a bit more complex then what i have shown in the post, but this should not be relevant to my problem. Anyhow, the database matches car makes, car models, years, engine liter and configuration to a cylinder head database.
Lets take this for example:
INSERT INTO part_car_match VALUES('AC101C', '1984-1987', "", 'Jeep', 'Wagoneer', "", "", "", '2.5L L4 150 CID');
INSERT INTO part_car_match VALUES('AC101C', '1984-2000', "", 'Jeep', 'Cherokee', "", "", "", '2.5L L4 150 CID');
INSERT INTO part_car_match VALUES('AC101C', '1986-1992', "", 'Jeep', 'Comanche', "", "", "", '2.5L L4 150 CID');
The Jeep Cherokee 2.5 Liter L4 between 1984 to 2000 is matched to the AC101C cylinder head.
Furtherdown on the list howerver there might be a
Jeep Cherokee 3.0 Liter matched to a different cylinder head.
By just taking all the results from the "model" row i would get duplicates of the 'Cherokee' which i don’t want.
Is this your question?
A possible solution to my problem might be to get ride of the entire loop all together and just load the array from a create database table just containing the current individual models. However, because this database will be updated somewhat frequently i would like to do this on the fly if possible instead of 'hard coding' the array of models.