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

    Join Date
    May 2000
    Posts
    3
    Rep Power
    0
    Hi im a newbie trying to take the arrays day and band
    into the (if month) script and then loop through arrays, inserting varibles into seperate records in a database, thus multiple records could be updated from one form.
    Is the problem my syntax or am I leaving something important out.

    <input type="hidden" name="day[]><br> <input type="text" name="band[]"><br>
    <input type="hidden" name="day[]><br> <input type="text" name="band[]"><br>
    <input type="hidden" name="day[]><br> <input type="text" name="band[]"><br>

    <input type="submit" name="makemonth">

    if ($makemonth) {
    while (list ($day, $band) = each ($HTTP_POST_VARS)) {

    insert day and band into database etc...

    }
    }
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    while (list ($day, $band) = each ($HTTP_POST_VARS)) {
    insert day and band into database etc...

    }


    actually you won't get the $day and $band in this way..

    you should separate your field name and values from the formfield.

    while (list ($name, $value) = each ($HTTP_POST_VARS)) {
    #separate the name and value from the form field.
    #get the name and values one by one.

    print $name.":".$value;

    }
    so you can't get the $day, $band values in single row for insertion.

    you should do this in a different way to insert this row.


    probably you can try something like this.

    $bands=$HTTP_POST_VARS[band];
    $days=$HTTP_POST_VARS[day];


    for($a=0;$a<count($bands);$a++){

    $query="INSERT INTO tbl set day='$days[$a]',band='$bands[$a]'";

    mysql_query($query,$connection);


    }


    <input type="hidden" name="day[]>

    remember,, you are not passing any value through this field.

    And also you are missing " thier.

    <input type="hidden" name="day[]">





    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited May 23, 2000).]

Similar Threads

  1. Referencing (many) form fields in an array
    By z974647 in forum ASP Programming
    Replies: 0
    Last Post: February 3rd, 2004, 11:12 AM
  2. arrays within arrays - looping through
    By kolatracks in forum PHP Development
    Replies: 2
    Last Post: February 1st, 2004, 02:16 AM
  3. From form write to file - array
    By TuxLives in forum PHP Development
    Replies: 0
    Last Post: January 25th, 2004, 01:22 AM
  4. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 06:40 PM
  5. Array query using <SELECT> form field
    By u230503 in forum ASP Programming
    Replies: 1
    Last Post: January 19th, 2004, 03:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo