Newcomers to help, the multi-line form as an array up into the database of a variety of small questions!
Because the needs of the site, need to do a page submission form, need to involve multi-line form as an array to submit to the database!
Degrees Niang Get an example:
is to set each field to [] The itinerary array upload, the processing code is:
!--? php
$db _name= "test";
$table _name= "Co_arr";
$connection = @mysql_connect ("localhost", "root", "smtroot") or Die (Mysql_error ());
$db = @mysql_select_db ($db _name, $connection) or Die (Mysql_error ());
mysql_query ("SET NAMES GBK");
Echo "";
Print_r ($_post["name"]);
Print_r ($_post["age"]);
Print_r ($_post["position"]);
//calculates the number of lines passed over the text box
$arr _length = count ($_post["name"]);
$name _arr = $_post["name"];
$age _arr = $_post["Age"];
$position _arr = $_post["position"];
/* Loop INSERT statement */
for ($i =0; $i < $arr _length; $i + +) {
$sql = "INSERT into Co_arr (name,age,position)";
$sql. = "VALUES (' $name _arr[$i] ', ' $age _arr[$i] ', ' $position _arr[$i] ')";
$query = @mysql_query ($sql, $connection) or Die (Mysql_error ());
//echo $_post["name" [$i]. "
";
}
?>