基本信息
源码名称:php 动态 增加 表单项并生成insert语句
源码大小:4.08KB
文件格式:.php
开发语言:PHP
更新时间:2015-12-01
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
php 动态 增加 表单项并生成insert语句
php 动态 增加 表单项并生成insert语句
<?php if($_POST){ //print_r($_POST); /*$num=count($_POST)-1; $content=array($_POST); //print_r($content[0]); for($i=0;$i<$num;$i ){ //echo $str="str".($i 1); echo "<br>"; //echo $$one;//=$content[0]["str".($i 1)]; echo $$str=$content[0]["str".($i 1)]; echo "<br>"; } ///////////////////////// echo "<hr>"; function su($i){ echo "insert into (str,str,str)values('".$str."','".$str."','".$str."')"; for($i=0;$i<$num;$i ){ } return $info1; } //echo su($num); echo "<hr>"; ////////////////////////////// echo $str1."<br>"; echo $str2."<br>"; echo $str3."<br>"; echo ($num/2)."<br>"; } */ echo "<hr>"; function kvavles($_where) { $where = ''; if (count($_where) > 1) { foreach ($_where as $wheres) { if($wheres !="提交查询内容"){ $where .= " , '".$wheres."'" ; } } $where = trim(" , ".$where, " , "); } else { $where = $_where[0]; } if ($where) { $sql = " ," . $where . " "; } else { } return $sql; } function keyname($_where) { $where = ""; if (count($_where) > 1) { foreach ($_where as $wheres=>$k) { if($wheres !="submit"){//$wheres !="提交查询内容" $where .= " , ".$wheres ; } } $where = trim(" , ".$where, " , "); } else { $where = $_where[0]; } if ($where) { $sql = "," . $where . " "; } else { } return $sql; } //echo kvavles($_POST); echo "<hr>"; //echo two($_POST); echo "inset into table(name".keyname($_POST).")values('".$name."'".kvavles($_POST).")"; } ?> <html> <head> <title>动态插入行</title> </head> <body> <table width="800" border="1"> <tr> <td> </td> <td align="center"> <table border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> <td><input type="button" value="新增" onClick="insertRows()"></td> </tr> </table></td> <td> </td> </tr> <tr> <td> </td> <td> <form action="gridadd.php" method="post" > <table border="1" width="40%" align="center" id="myTable"> <tr> <td width="20%">合同协议</td> <td width="10%">公章数量</td> <td width="20%">法人章数量数量</td> <td width="10%">删除</td> </tr> </table> </td> <td> </td> </tr> <tr> <td> </td> <td align="center"> <input type="submit" name="submit"/> </form> </td> <td> </td> </tr> </table> </body> </html> <script language="javascript"> var tempRow=0;//用于存放临时行 var maxRows=0; function insertRows(){ tempRow=myTable.rows.length-1; maxRows=tempRow; tempRow=tempRow 1; var myRows=myTable.rows; var newRow=myTable.insertRow(myTable.rows.length);//插入新的一行 var myCells=newRow.cells; for(i=0;i<4;i ){//每行共三列 var newCell=myRows(newRow.rowIndex).insertCell(myCells.length); newCell.align="center"; switch(i){ case 0: newCell.innerHTML="<td valign='top'><input type='text' name='str" tempRow "' width='30' value='1111'></td>"; break; case 1: newCell.innerHTML="<td valign='top'><input type='text' name='gnum" tempRow "' width='30' value='2'></td>"; // newCell.innerHTML="<td valign='top'><select name='xnum" tempRow "'><option value='content1' selected>内容一</option><option value='content2'>内容二</option></select></td>"; break; case 2: newCell.innerHTML="<td valign='top'><input type='text' name='fnum" tempRow "' width='30' value='2'></td>"; break; case 3: newCell.innerHTML="<td valign='top'><a href='javascript:delTableRow(\"" tempRow "\")'>删除</a></td>"; break; } } maxRows =1; } function delTableRow(rowNum){ if(myTable.rows.length>rowNum){ myTable.deleteRow(rowNum); } } </script>