The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

remove empty values from an array

I have been using this instructional from the Wrox Book PHP Programing as the basis for my own much larger form. This first part generates 3 forms with first and last names fields as arrays. My form does the same except has about 30 or so rows and 5 array fields.

The problem is when I iterate through my form using the above code, every row including the ones that were not filled in also get inserted into the database

I assume that the same thing is going to happen with the above example that I am trying to use to learn from. What if only the first form is filled in, is it then okay to have two extra empty rows added to the database?

there must be a simple solution for this? someway to discard empty rows.

Yeah, I gathered that. In my form located herehttp://www.mantaproductions.com/arro.../testtable.php
each row has a checkbox which must be checked if any of the fields on that row will have a value. Empty values in the row is cool, I just want to avoid all those empty rows where the checkbox has not been checked. I am trying to use that code you posted on the checkbox variable only but Im getting mixed up on where exactly I should put it. Here is the code the way I have it now but it still inserts every row even the ones the checkbox has not been checked on

Thanks Powerlord, I am going to study your code. I think the code I am using will work for now (translated: I dont have time to keep working on this detail ) but I have to learn these options so when I have time I will experiment with this.

One thing I was wondering if there was a way to insert the entire array in one single query, though not sure if that would be better anyway. This is not a heavy load form. Only one person writing to it at a time and max 40 times per day.