Hi I'm very new to PHP programming so i hope this is clear -
I have a form which submits two different arrays for processing - One is a checkbox type with the code:
<input type='checkbox' value='$name' name='name[$i]'>
and the other is a text box type with the code:
<input type=text size=10 name='consumed[$i]'>
They are both within a for loop:
for ($i = 0; $i < mysql_num_rows($query_result); $i++) {
When they are passed to the form - The user selects a checkbox and provides information within the text box for the specified checkbox.
The problem i'm having is that the arrays are passed with structures like this
Array
(
[1] => celery
[3] => chocolate
)
Array
(
[0] =>
[1] => 10
[2] =>
[3] => 15
[4] =>
)
When i come to process the array I'm trying to insert into a database the value, for example of celery and 10 as they have matching keys but i cant find a way to process both at the same time within a for loop as it throws back an error when trying to process the blank elements in the second array.
Is there a way to alter the two arrays before i use them so they have exactly the same structure or use foreach to somehow process one array and match the key being used to the other array?
Sorry if this doesn't make much sense - I will try to clarify if it's needed
Any help is appreciated,
Thanks