I'm having a few issues with foreach loops in PHP.
I have an outer foreach loop and an inner foreach loop.
The basics of the loops are, I have some posted data from a form, and some data from a db. The outer loop, loops through each post data and then compares this with data from the database inner loop.
The issue I have is, upon each outer loop, if an entry is found on the inner loop, how does the outer loop know its been found and then not repeat the entry.
So, here's the code I am using, i've commented so you can see the problem im having with the logic
// get posted data
foreach($posted_vals as $post_key => $post_value) {
// query all data in assignments table
foreach($existing_ids as $db_key => $db_value) {
// check if user_id($db_value) matches ($post_value),
// if not then post to db
// if this loop does not find matching data and
// posts to the database, how does the outer loop
// know its been found and then not post again to database
}
// any entries not found in db, post to db ... er but hang on,
// how do i know if any entries were posted???
}
breakif the test is true