2017-02-22 01:08
浏览 49


How I can process a dynamic form. Number of options will vary by the number of options from the database. Based on yes/no value will be updated in the database is user want to test that parameter. Here is my code

<form action="?userid=<?php echo $userid;?>&tankid=<?php echo $tankid;?>&action=update" method="POST">
    <table width="100%">
            <th >Parameter name:</th>
            <th >Do you want to test it?</th>

        while ($row = $records_param_info->fetch(PDO::FETCH_ASSOC)){
            $checked_yes = "";
            $checked_no = "";
            echo "<tr>";
            echo "<td>";
            echo $row['paramname'];
            echo "</td><td>";
            if ($row['active'] == 1){
                $checked_yes = "checked";
                $checked_no = "";
            } else {
                $checked_yes = "";
                $checked_no = "checked";
            echo '<label>Yes</label><input type="radio" name='.$row['parameterid'].' '.$checked_yes.' value="1">';
            echo '<label>No</label><input type="radio" name='.$row['parameterid'].' '.$checked_no.' value="0">';
            echo "<td></tr>";


    <center><input type="submit" name="Update" value ="Update"></center>

My question will be how to retrieve the data and processes it to the databse since the "name" will be always different and the number will be different.

图片转代码服务由CSDN问答提供 功能建议

如何处理动态表单。 选项数量因数据库中的选项数量而异。 基于是/否的值将在数据库中更新,用户希望测试该参数。 这是我的代码</ p>

 &lt; form action =“?userid =&lt;?php echo $ userid;?&gt;&amp; tankid =&lt;?php echo $ tankid;  ?&gt;&amp; action = update“method =”POST“&gt; 
&lt; table width =”100%“&gt; 
&lt; tr&gt; 
&lt; th&gt;参数名称:&lt; / th&gt;  
&lt; th&gt;你想测试吗?&lt; / th&gt; 
&lt; / tr&gt; 
 while($ row = $ records_param_info-&gt; fetch(PDO:  :FETCH_ASSOC)){
 $ checked_yes =“”; 
 $ checked_no =“”; 
 echo“&lt; tr&gt;”; 
 echo“&lt; td&gt;”; 
 echo $ row ['paramname'  ]; 
 echo“&lt; / td&gt;&lt; td&gt;”; 
 if($ row ['active'] == 1){
 $ checked_yes =“checked”; 
 $ checked_no =“”;  
} else {
 $ checked_yes =“”; 
 $ checked_no =“checked”; 
 echo'&lt; label&gt;是&lt; / label&gt;&lt; input type =“radio”name ='。  $行[ '参数标识']“。  '$ checked_yes。'  value =“1”&gt;'; 
 echo'&lt; label&gt; No&lt; / label&gt;&lt; input type =“radio”name ='。$ row ['parameterid']。'  '$ checked_no。'  value =“0”&gt;'; 
 echo“&lt; td&gt;&lt; / tr&gt;”; 
&lt; / table&gt; 
&lt; br&gt;  ; 
&lt; center&gt;&lt; input type =“submit”name =“Update”value =“Update”&gt;&lt; / center&gt; 
&lt; / form&gt; 
 </ code> </ pre> \  n 

我的问题是如何检索数据并将其处理到数据库,因为“名称”总是不同的,数字也会不同。</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题