Michael Viox Michael Viox - 1 month ago 11
PHP Question

Emailing submitted form of a SQL array

~edit

I have been working this same issue for a few days now. I am trying to change individual fields (dimensions) within an array pulled from a query, then email myself the result. Here is what I have so far...

//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>";


The part of code "name='". $key['PT_N'] ."_length' is a feeble attempt at trying to change the names of the input fields dynamically. The issue I am having, I need to be able to call these fields on a mail.php page, but I haven't figured out how to reference each one by $_POST...

//mail.php

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


The above code helped quite a bit, yet it is only returning one line from form.php. Here is the output I get... however; there are actually 20 rows to this... "No trade secrets have been published" :P


POST parameter 'PT_N' has '4338892'POST parameter 'Item_ID' has
'KOHK-14484-BGD'POST parameter 'Bin' has 'BOXFIX01'POST parameter
'Length' has '3.000000000'POST parameter 'Width' has '2.500000000'POST
parameter 'Height' has '2.000000000'

Answer

You can do

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