Raspuns: [PHP] Multiple Inserts With PHP
| From: | Ovidiu EFTIMIE | Date: | Thu, 19 Oct 2000 15:59:21 +0000 |
| Subject: | Raspuns: [PHP] Multiple Inserts With PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21170@lists.php.net to get a copy of this message | ||
You should also name your drop down list something like this ddlist[] in
order to create an array . If you don't do that only the last chosen option
will be available.
Ovidiu
-----Mesaj original-----
De la: root@dual.crnetworks.it [mailto:root@dual.crnetworks.it]In numele
Roberto Cespa
Trimis: Thursday, October 19, 2000 1:01 PM
Catre: Phillip S. Baker
Cc: php-general@lists.php.net
Subiect: Re: [PHP] Multiple Inserts With PHP
I use postgresql, so I don't know command syntax for mysql, but the code is
very similar.
for($i=0; $i < sizeof($array_of_data); $i++)
{
$query = "insert into table values('".$array_of_data[$i]."')";
$result = pg_exec($connection,$query);
}
Hope this helps,
Roberto Cespa
"Phillip S. Baker" wrote:
> Greetings Folks,
>
> I have a form with a drop down list. The user can select multiple options
> from the list and of course the options get plugged into an array.
>
> Now what I want to know is how to take the information from the array and
> make multiple inserts into a MySQL table.
>
> So I would have an array with the following values.
>
> A
> B
> C
>
> And I want each to insert as a different record in a table so in the table
> it would be inserted as
>
> id value
> 1 A
> 2 B
> 3 C
>
> Now I am suspecting that I need to use some sort of do...while or for loop
> loop that would pull the first value from the array and run an insert
> statement in the DB, then increment the place the array by one and run
> again. But my brain is not figuring out how exactly this would be written.
> Can anyone help me out?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Colombo2000
http://www.colombo2000.it
Il tuo prossimo viaggio comincia qui
+---------------------------------------------+
| Roberto Cespa |
| Responsabile Ricerca e Sviluppo Colombo2000 |
| Email: rcespa@colombo2000.it |
| Mobile: +39-380-3042732 |
+---------------------------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net