사용자는 addmore 버튼을 통해 입력 필드를 더 추가 할 수있는 다음과 같은 양식이 있습니다. 내 질문은 어떻게 POST에서 배열을 검색하고 그들을 밖으로 울릴 수 있습니다. 볼 수 있듯이 나는 name product [] 및 quantity [] (더 많은 필드를 추가 할 수 있음)라는 두 개의 입력 필드가 있습니다. foreach 루프를 사용하여 필드 값을 가져와 mail()에 사용할 varibla $ 메시지에 저장해야합니다. 둘 다 각 루프를 시도했다 내 아래 각 루프 코드PHP에서 배열로 텍스트 필드를 검색하는 방법
$product = $_POST['product'];
$quantity = $_POST['quantity'];
foreach($product as $value)
{
$message = "<html><head>
<title></title>
</head>
<body>
<table>
<tr>
<td>".$value."";
}
foreach($quantity as $value)
{
$message.=" </td>
<td>".$value."</td>
</tr>
</table>
</body>
</html>";
}
내 입력 폼
<form id="quick_post" method="post">
<table id="input_fields">
<tr>
<td><input class="orderinput" type="text" name="product[]" /></td>
<td><input class="orderquan" type="text" name="quantity[]" size="1" maxlength="3" /></td>
</tr>
</tr>
</table>
<input class="more" type="button" value="Addmore" name="addmore" /> // a jquery script is processed on click to add more fields.
<input class="send" type="submit" value="Send" name="send" /></form>
이것의 출력은 나 제품의 첫 번째 행에 대한 인쇄 얻을 수있다 나머지 행은 수량 만 인쇄되거나 에코됩니다.
Product Name Quantity
aaaaaa 22
33
당신이 당신의 루프에서 헤드/제목 태그 등을, 당신 이러한 반복 싶지 않아 –
내 시도는 HTML 메일을 보내는 것입니다. 내 생각에, 나는 html과 head 태그를 루프의 우리의 것으로 옮길 수있다. –