This title might not describe my question too well but I was unsure how to name this post... Anyways, I have a form that has dynamically generated input boxes that pulls the last 4 years with the following:
<?php
$current_date = new DateTime();
for ($i = 1; $i <= 4; $i++) {
$current_date->modify('-1 year');
$date_string = $current_date->format('Y')
?>
<fieldset name="gross_sales">
<input type="number" name="year_brand_gross[<?php echo $date_string; ?>]" placeholder="Gross Sales for <?php echo $date_string; ?>">
</fieldset>
<?php
} // end while
?>
And once the user clicks submit the form data is processed via my process.php file that contains the following:
$year_brand_gross[1] = $_POST['year_brand_gross'][1];
$year_brand_gross[2] = $_POST['year_brand_gross'][2];
$year_brand_gross[3] = $_POST['year_brand_gross'][3];
$year_brand_gross[4] = $_POST['year_brand_gross'][4];
Now I'm pretty sure the above part is not right. So this is my question... How would I get the info from these inputs into my email that's sent since their created by an array and not "actually" there. Here's a stripped down version of my html email that's sent which I'm pretty sure is also wrong since the above code is incorrect:
<table>
<tr>
<td>Gross Sales:</td>
</tr>
<tr>
<td>{$year_brand_gross[1]}</td>
<td>{$year_brand_gross[2]}</td>
<td>{$year_brand_gross[3]}</td>
<td>{$year_brand_gross[4]}</td>
</tr>
</table>
Any help is greatly appreciated!
$_POST['year_brand_gross'][1]should be changed to$_POST['year_brand_gross'][2012]