包含表格和foreach的HTML电子邮件

时间:2017-04-15 13:28:34

标签: php forms algorithm loops foreach

我有一个动态表单,我可以在其中添加或删除发送到电子邮件的字段。我在电子邮件中制作了一个html表格,我需要根据添加的"产品数量添加一行"。有我的想法的图片(抱歉我的绘画技巧)。 Pic of the problem 有html + php代码。我应该把它翻译成英文吗?

我希望你理解我的问题。请问你能帮帮我吗?我尝试过很多不同的循环变化,但我不能这样做。谢谢

<table name='contact_seller' style='border-collapse:collapse';> 
            <thead>
                <tr>
                    <th style='width:auto;padding-right: 15px;'>typ dílu</th>
                    <th style='width:auto;padding-right: 15px;'>Počet kusů</th>
                    <th style='width:auto;padding-right: 15px;'>Číslo dílu</th>
                </tr>    
            </thead>
            <tbody>";
                foreach($typ_dilu['val'] as $key=>$val) { 
                    $message .="
                        <td>" . $val ."</td>";
                 } 
                 foreach($pocet_ks['val'] as $key=>$val) { 
                    $message .="
                        <td>" . $val ."</td>";
                 } 
                foreach($cislo_dilu['val'] as $key=>$val) { 
                    $message .="
                        <td>" . $val ."</td>";
                 } 

            $message .= "</tbody>
</table>

&#13;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
 <script type="text/javascript" src="http://www.vykupmotoru.cz/wp-content/themes/motory/scripts/script.js"></script>
<form action='#' class="" method="POST" enctype="multipart/form-data" name="myform" id="myform" >

            <fieldset class="row2">
				<h3>Informace o dílu</h3>
					<input style="margin: 5px 5px 5px 5px;" type="button" id="add" value="Přidat díl" /> 
					<input style="margin: 5px 5px 5px 5px;" type="button" id="delete" value="Odebrat díl" /> 
               <table id="dataTable" class="form" border="1" style="max-width:960px; width:100%">
                   <tbody class="template" id="0">
                    <tr>
<td>
							<div class="form_item">
							<p class="form_label"><label>Typ dílu:</label></p>
							<p class="form_input"><span class=""><select name="typ_dilu[val][0]"><option value=""></option><option value="Vstřikovač">Vstřikovač</option><option value="Palivové čerpadlo">Palivové čerpadlo</option><option value="Turbo">Turbo</option><option value="EGR ventil">EGR ventil</option><option value="Startér">Startér</option><option value="Alternátor">Alternátor</option><option value="Klima kompresor">Klima kompresor</option><option value="Servo řízení">Servo řízení</option><option value="Převodovka">Převodovka</option><option value="Brzdový třemen">Brzdový třemen</option></select></span></p>
							<p></p>
							</div>					
						</td>
						
						<td>
							<div class="form_item">
							<p class="form_label"><label>Počet kusů:</label></p>
							<p class="form_input"><span class=""><input type="number" name="pocet_ks[val][0]"></span></p>
							<p></p>
							</div>
						</td>
						 <td>
							<div class="form_item" >
							<p class="form_label"><label>Číslo dílu:</label></p>
							<p class="form_input"><span class=""><input type="text" name="cislo_dilu[val][0]"  required value="" size="40"></span></p>
							<p></p>
							</div>
							 </td>
					</tr>
						
                    </tbody>
					
                </table>
				
				<div class="clear"></div>
            </fieldset>
			<div class="row_form">
				<div class="form_submit">
					<p><input type="submit" name="submit" value="Odeslat poptávku"></p>
					<p></p>
				</div>
			</div>
        </form>
&#13;
&#13;
&#13;

0 个答案:

没有答案