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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.