posted June 22, 2000 08:07 AM
I have a question that is dificult to explain but I will give it my best. I have 8 sets of 3 arrays which are enter from an HTML form in the form of a check box, text field and text area.
If a check box is marked I need the information from the text area and test field to be entered as the same field
in the MySQL DB. I did this by having the php code loop through the amout of time as I have check marks. All works
great if I have all check boxes but it all screws up if I have anythin but the first check box checked. I know
this a pretty cryptic discription but have a look at the code and see if any one can help.
NOTE: If I do a count on the arrays the text field and text area they are always 8 and the check box count depends
on how many I have checked. So I believe what is happening enven though I am not putting data int the text field
and text are it is entering this info as blank fields into my DB throwing every thing out of wack.
Thanks
HTML CODE
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="1"> A-Surface
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="2"> B-Surface
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="3"> Drawing
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="4"> Attachments
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="8"> Feasibility
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="5"> P.I.S.T.
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="6"> Data Translation
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td><tr><td>
<input type="checkbox" name="WORK_TYPE_ARRAY[]"value="7"> Engineering Change
Date Required:<input name="TOW_DATEREQ_ARRAY[]" size=10 maxlength=10>
<BR>Instructions:<BR><TEXTAREA cols=50 rows=5 name="TOW_INST_ARRAY[]"></TEXTAREA></td>
PHP CODE to enter data into DB
$numrows = count ($WORK_TYPE_ARRAY);
for ($i = 0; $i < $numrows; ++$i) {
$sql2 = "INSERT INTO tow_details (wo_id, tow_id, tow_datereq, tow_inst) VALUES
('$worknum', '$WORK_TYPE_ARRAY[$i]', '$TOW_DATEREQ_ARRAY[$i]', '$TOW_INST_ARRAY[$i]')";
$result2 = mysql_query($sql2) or die ("Query Failed");
}
THANKS!!!