Submit multiple text box value with same name to php

I have written a program with display text boxes as per user selected number.
So,I don’t know how to submit value of multiple text boxes with same name to php database.
So please help me.

[code]

Passengers * : 123456
 <td><input type="text" name="paxNm[]" id="paxNm1" autocomplete="off"/>
[font=courier][size=10pt][/size][/font] //
# Name Age Gender
MaleFemale GenVIPHANDICAPPEDMD Quota
[/code]

I had a minute so I did a PDO for you. This has no validation or anything. It is just to show you how to get your array into the database ONLY.

CREATE TABLE `datatable` ( `pacnm` varchar(255) DEFAULT NULL, `age` varchar(20) DEFAULT NULL ) ENGINE=InnoDB;

[php]<?php
if ($_POST){

try {
$db = new PDO(“mysql:host=localhost;dbname=phphelp_form_array”, “root”, “”);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$insertStmt = $db->prepare(“INSERT INTO datatable (pacNm, age) VALUES (?,?)”);

for ($i = 0; $i < count($_POST[‘pacNm’]); $i++)
{
$insertStmt->execute(array(
$_POST[‘pacNm’][$i],
$_POST[‘age’][$i]
));
}
}// End Try

catch (PDOException $e)
{
echo 'ERROR: ’ . $e->getMessage();
}

}// End Post
?>

PacNm 1
PacNm
Age
PacNm 2
PacNm
Age [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service