I have a form that contains 8 columns and a variable number of rows that I need to send an email to a client in a well formatted email. The form represents the required fields as a multidimensional array. Example below:
<input name="order[0][topdiameter]" type="text" id="topdiameter0" value="1" size="5" /> <input name="order[0][bottomdiameter]" type="text" id="bottomdiameter0" value="1" size="5" /> <input name="order[0][slantheight]" type="text" id="slantheight0" value="1" size="5" /> <select name="order[0][fittertype]" id="fittertype0"> <option value="harp">Harp</option> <option value="euro">Euro</option> <option value="bulbclip">Regular</option> </select> <input name="order[0][washerdrop]" type="text" id="washerdrop0" value="1" size="5" /> <select name="order[0][fabrictype]" id="fabrictype"> <option value="linen">Linen</option> <option value="pleated">Pleated</option> </select> <select name="order[0][colours]" id="colours0"> <option value="beige">Beige</option> <option value="white">White</option> <option value="eggshell">Eggshell</option> <option value="parchment">Parchment</option> </select> <input name="order[0][quantity]" type="text" id="quantity0" value="1" size="5" />
This form is formatted in a table, and rows can be added to it dynamically. What I was not able to do was get the formatted table from the array.
This is what I am currently using (grabbed from the network).
<?php if (isset($_POST["submit"])) { $arr= $_POST['order'] echo '<table>'; foreach($arr as $arrs) { echo '<tr>'; foreach($arrs as $item) { echo "<td>$item</td>"; } echo '</tr>'; } echo '</table>; }; ?>
This works fine for a single row of data. If I try to send 2 or more lines from the form, one of the columns will disappear. I would like the table to be formatted as:
| top | Bottom | Slant | Fitter | Washer | Fabric | Colours | Quantity | ------------------------------------------------------------------------ |value| value | value | value | value | value | value | value |
with extra lines as needed. But I can not find examples that will generate this type of table!
It seems like this should be something pretty simple, but I just can't find an example that works the way I need it.
source share