Page 1 of 1

sql update multiple textboxs

Posted: Tue Feb 09, 2010 3:29 pm
by incubi
Hello,

I need to do a table update for one column and an unknown number of records. The column will have text boxes for each record displayed so the user can add values. The problem I run into is if my code looks like this

Code: Select all

 
<INPUT TYPE=text SIZE=3 maxlength=5 NAME=$ary[] value="">
 
Then I have no record key to know where to put the values. If I display the table with NAME set to the record key like so

Code: Select all

 
INPUT TYPE=text SIZE=3 maxlength=5 NAME='.$row["ID"].' value="">
 
Then I don’t know how to update the table with the posted data.

Any ides, anyone?

Thanks,

incubi

Re: sql update multiple textboxs

Posted: Tue Feb 09, 2010 3:39 pm
by AbraCadaver
You could try this:

Code: Select all

echo '<INPUT NAME="data[' . $row['id'] . ']">';
Then to process, loop through $_POST['data'] and use the key as the row id:

Code: Select all

foreach($_POST['data'] as $key => $value) {
    // use key and value
}

Re: sql update multiple textboxs

Posted: Tue Feb 09, 2010 4:22 pm
by incubi
I'll be a two in a world full of ones and zeros!! It worked! I have a name val pair I can use and so easy too. It's clear I need to study up on array usage. I'll let you know what happens, if anything, when I submit 900 records with method.


Thanks much!

incubi