爆炸textarea条目并具有表单发送数组

时间:2014-07-16 15:25:41

标签: php arrays database forms

我有一个textarea,询问用户流程。用户可以输入由逗号分隔的多个流。我希望能够将该条目分解为数组并将该数组传递给表单而不是条目变量($ lot_entry)。不确定如何去做。尝试解决方案如下:

    print "<form name=\"entry1\" method=\"get\" ".
        "action=\"process_crawl_chart_plot.php\">\n";   
            print "<table border=\"1\" cellspacing=\"2\" cellpadding=\"8\">\n";         
    print "<tr>\n";
    print "<th bgcolor=\"#E9E9E9\"><font size=\"-1\">Enter Lot(s) Of The Same Flow\n Separated By Spaces</th>\n";
    print "<td colspan=\"2\">\n";
    print "<textarea cols=\"40\" rows=\"5\"  name=\"lot_entry\">$lot_entry</textarea>\n";
    print "</td>\n";
    print "</tr>\n";


    print "<input type=\"hidden\" name=\"chosen_lot[]\" value=\"$chosen_lot\">\n";
    print "<input type=\"hidden\" name=\"serial_flow\" value=\"$serial_flow\">\n";          
    print "<td align=\"center\" colspan=\"2\">\n";
   print "<button name=\"process_action\" type=\"submit\" value=\"Graph\"".
         "style=\"color: green\"><b>Select</b></button>\n";
    print "</tr>\n";
    print "</tr>\n";
    print "</form>";

if (!empty($_POST['lot_entry']))    {       
    $chosen_lot_entry_arr = explode(' ',$_POST['lot_entry']);
    foreach($chosen_lot_entry_arr as $lot_entry1){
    $query = "SELECT serial_ls FROM lot_start WHERE lot = '$lot_entry1'";
    if ($show_query == 1) { print "<font size=\"-2\">".$query."</font>\n"; }
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
   $temp_data = mysql_fetch_row($result);
    while ($temp_data = mysql_fetch_row($result)) {    
    $chosen_lot[] = $temp_data[0];  
    }       
}

}

1 个答案:

答案 0 :(得分:0)

尝试使用explode(' ', $lot_entry)。这将使每个单词成为数组中的不同元素。