sql update multiple textboxs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

sql update multiple textboxs

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: sql update multiple textboxs

Post 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
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
incubi
Forum Contributor
Posts: 119
Joined: Mon Dec 07, 2009 1:47 pm

Re: sql update multiple textboxs

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