Jump to content

Looking for an orphan (comparing arrays)


tHud

Recommended Posts

Hello  :)

 

(I think this is more of a php question than MySQL - sorry if I have got it wrong.)

 

I need to know if items have been orphaned (because they lack a cat_id that actually exists).

 

 

I have two MySQL tables that each have fields 'cat_id'.

 

I have a Category table...

 

cat_id / category

1 / fruit

2 / veg

3 / tools

 

 

I have another product table

 

cat_id / product

1 / apple

1 / Pear

2 / carrot

2 / cabbage

3 / screwdriver

1 / peach

8 / orphan

 

I have entered the data into two arrays...

 

$categories[]

$products[]

 

I have tried a number of combinations of foreach loops to try to determine if the products(cat_id) doesn't match the categories(cat_id) but I seem to be going around in circles.

 

Is there perhaps a function that is available to do this?

 

Or maybe just a straight thinking person that can point out my ineptitude?

 

Thank you for any input.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/216032-looking-for-an-orphan-comparing-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.