通过电子邮件发送提交的SQL数组表单

时间:2016-10-24 19:59:59

标签: php sql odbc html-email

〜编辑
我已经在同一个问题上工作了几天了。我试图更改从查询中提取的数组中的单个字段(维度),然后通过电子邮件发送结果。这是我到目前为止所拥有的......

//form.php
    echo "<table id='tableTop'>";
    echo "<tr>";
    echo "<th>Pick Ticket</th>";
    echo "<th>Item ID</th>";
    echo "<th>Bin</th>";
    echo "<th>Length</th>";
    echo "<th>Width</th>";
    echo "<th>Height</th>";
echo "</tr>";
while($key = odbc_fetch_array($rows)){
echo "<form id='Email_Fix' method='post' action='mail.php'>";
echo "<tr>";
    echo "<td><input type='text' name='PT_N' value=".  $key['PT_N'] ." readonly></td>";
    echo "<td><input type='text' name='Item_ID' value=".  $key['Item_ID'] ." readonly></td>";
    echo "<td><input type='text' name='Bin' value=".  $key['Bin'] ." readonly></td>";
    echo "<td><input type='tel' step='0.01' pattern='[0-9\.]*' name='Length' value=" . $key['Length'] . " size='10'></td>";
      echo "<td><input type='tel' step='0.01' pattern='[0-9\.]*' name='Width' value=" . $key['Width'] . " size='10'></td>";
    echo "<td><input type='tel' step='0.01' pattern='[0-9\.]*' name='Height' value=" . $key['Height'] . " size='10'></td>";
   echo "</tr>";
echo "<tr>";

代码部分&#34; name =&#39;&#34;。 $ key [&#39; PT_N&#39;]。&#34; _length&#39;尝试动态更改输入字段的名称是一种微弱的尝试。我遇到的问题是,我需要能够在mail.php页面上调用这些字段,但我还没有想出如何通过$ _POST来引用每个字段...

//mail.php

foreach($_POST as $key => $value) {
  echo "POST parameter '$key' has '$value'";
}

上面的代码帮了很多,但它只从form.php返回一行。这是我得到的输出......但是;实际上有20行...&#34;没有发布任何商业机密&#34; :P

  

POST参数&#39; PT_N&#39;有&#39; 4338892&#39; POST参数&#39; Item_ID&#39;具有   &#39; KOHK-14484-BGD&#39; POST参数&#39; Bin&#39;有&#39; BOXFIX01&#39; POST参数   &#39;长度&#39;有&#39; 3.000000000&#39; POST参数&#39;宽度&#39;有&#39; 2.500000000&#39; POST   参数&#39;高度&#39;有&#39; 2.000000000&#39;

〜更新

我得到了它的工作,但是......我更进一步,创造了一个功能

$msg = "<p> Mike!</p><p> Here is your stuff!\n\n
<table id='tableTop'>
<tr>
<th>Pick Ticket</th>
<th>Item ID</th>
<th>Bin</th>
<th>Length</th>
<th>Width</th>
<th>Height</th>

</tr>";
function Fixit($loop, $num){

foreach($_POST[$loop] as $key => $num){
   echo "<td>" . $num . "</td>";
};
};

$msg1 = " <tr>" . Fixit('PT_N', '0') && Fixit('Item_ID', '1') && Fixit('Bin', '2') && Fixit('Length', '3') && Fixit('Width', '4') && Fixit('Height', '5') ."</tr>";

echo $msg, $msg1;

那不起作用?

1 个答案:

答案 0 :(得分:0)

你可以做到

foreach ($_POST as $key => $value) {
   // $key = name of the input
   // $value = value of the input
}