My database has a table of products with similar names except for the numeric end. So the products might look like:
prod1-30
prod1-36
prod2-24
prod2-30
I need to have all of the products have all of the proper endings. If one doesn't exist, I need to add it to the database so that it ends up looking like this:
prod1-24
prod1-30
prod1-36
prod2-24
prod2-30
prod2-36
To do this, I came up with this code to find the missing products:
This will work on the first pass but when it goes back to check the next "type," the code gets skipped. I thought it has something to do with the array pointer but using reset($products_query) results in an invalid argument error.
Would someone please point out my mistake? Is there a better way to code what I need to do?