#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    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!!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    London
    Posts
    46
    Rep Power
    15
    I don't have much time to explain this so I lined up the HTML so it was numbered 1-8 in order, so that you can reference the arrays using this. I then used the var $j - 1 for this figure.
    It goes through each array value in $WORK_TYPE_ARRAY, gets the value, and uses it to reference the other arrays.

    Well here's the code, you might want to replace the replace the;
    $result2 = mysql_query($sql2) or die ("Query Failed");
    with
    print("$sql2<BR>n");

    to make sure that it gives you what you want.

    *********HTML*********

    <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="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>

    <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>


    *******PHP***********

    $numrows = count ($WORK_TYPE_ARRAY);

    for ($i = 0; $i < $numrows; $i++) {

    $j = $WORK_TYPE_ARRAY[$i] - 1;

    $sql2 = "INSERT INTO tow_details (wo_id, tow_id, tow_datereq, tow_inst) VALUES
    ('$worknum', '$WORK_TYPE_ARRAY[$i]', '$TOW_DATEREQ_ARRAY[$j]', '$TOW_INST_ARRAY[$j]')";

    $result2 = mysql_query($sql2) or die ("Query Failed");

    }

    Kelvin
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    Thank you I tested and it look great!!!

Similar Threads

  1. Replies: 15
    Last Post: February 27th, 2005, 04:25 PM
  2. 3 fields for Telephone, instead of one ?
    By lazyjunk in forum PHP Development
    Replies: 35
    Last Post: October 23rd, 2003, 06:39 PM
  3. multipage form: sessions or hidden fields?
    By Ssy in forum PHP Development
    Replies: 7
    Last Post: June 24th, 2003, 10:20 AM
  4. subroutine causes unexpected delection of fields
    By karsh44 in forum Visual Basic Programming
    Replies: 2
    Last Post: June 18th, 2003, 09:31 AM
  5. Copy Record Button that copies Selective fields only
    By Dean Warrington in forum Visual Basic Programming
    Replies: 1
    Last Post: May 11th, 2003, 06:43 AM

IMN logo majestic logo threadwatch logo seochat tools logo