form values into an array
Posted: Sat Mar 12, 2005 7:51 pm
i have a form, with text fields storing data in an array. each will be a row of data in the db.
<input name="value[]" type="text">
<input name="id[]" type="hidden" value="<?php print $id; ?>">
i have two questions.
how do i get these value into the db? i've been accessing each element by it's number in a while loop. ex: insert $value[1], id[1], insert $value[2]...
i'm sure this isn't the best way to do this.
also, i'm not requiring that all the fields in the form have data and am getting zero values. how do i make it so these values are never stored in the array? my idea was to only insert, into the db, the values that were not zero. is there a more efficient way?
<input name="value[]" type="text">
<input name="id[]" type="hidden" value="<?php print $id; ?>">
i have two questions.
how do i get these value into the db? i've been accessing each element by it's number in a while loop. ex: insert $value[1], id[1], insert $value[2]...
i'm sure this isn't the best way to do this.
also, i'm not requiring that all the fields in the form have data and am getting zero values. how do i make it so these values are never stored in the array? my idea was to only insert, into the db, the values that were not zero. is there a more efficient way?