简体   繁体   English

在PHP中定义动态表单ID

[英]Defining dynamic Form ID in PHP

I want to define dynamic form id for the following example form. 我想为以下示例表单定义动态表单ID。

The following code doesn't give me the result I want. 以下代码没有给我我想要的结果。 for example, instead of <form id="form1"> , 例如,代替<form id="form1">
I get this result : <form id='form''1'> 我得到以下结果: <form id='form''1'>

How should I write it so it gives me the result I want? 我应该怎么写,这样才能给我想要的结果? Thanks !! 谢谢 !!

<?php 

    while ($data = mysqli_fetch_array($subject)) {

    echo "<form id='form'.'{$data['productID']}' method='post' action=' ' data-checktable='{$data['productID']}'>";
        echo "<input type='checkbox'  class='SelectAll'>All";
        echo "<label><input type='checkbox'  class='selector' value='{$data['product1']}'>" . $data['product1']."</label>";
        echo "<label><input type='checkbox'  class='selector' value='{$data['product2']}'>" . $data['product2']."</label>";
        echo "</form>";
         }
    ?>

You just need to Change it to 您只需要将其更改为

echo "<form id='form{$data['productID']}' method='post' action=' ' data-checktable='{$data['productID']}'>";

ie remove the extra '.' 即删除多余的'.' between the word form and the ID you wanted. form和您想要的ID之间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM