• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

js动态添加行后,往数据库中插入数据的有关问题

php 搞代码 4年前 (2022-01-24) 31次浏览 已收录 0个评论

js动态添加行后,往数据库中插入数据的问题

HTML code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><!---ecms html部分--><script language="JavaScript"> var cGetRow=-99999;function insertrow(){var newrow = document.all.ACE_HIDDEN_TABLE.rows[0].cloneNode(true); //克隆一行document.all("newTB").appendChild(newrow); //添加刚才克隆的一行}function GetRow(){//获得行索引//两个parentElement分别是TD和TR,rowIndex是TR的属性//this.parentElement.parentElement.rowIndexcGetRow=window.event.srcElement.parentElement.parentElement.rowIndex;DelRow(cGetRow);//点击checkbox时,直接删除行。}function DelRow(iIndex){//删除一行if(iIndex==-99999){alert("系统提示:没有选中行号!");}else{newTB.deleteRow(iIndex);iIndex==-99999;//将rowIndex恢复默认<em style="color:transparent">本@文来源[email protected]搞@^&代*@码网(</em><q>搞代gaodaima码</q>值。}}</script><table border="1"><tr>    <td width="40">删除</td>    <td width="40">登记</td>    <td width="70">用户号码</td>    <td width="150">建筑名称</td></tr>     <tbody id="ACE_HIDDEN_TABLE">  <tr>    <td width="40"></td>    <td width="40"></td>    <td width="70"></td>    <td width="150"></td>  </tr></table><table width="1250" border="1"><!---ecms  插入新行的区域 begin --><tbody id="newTB"></tbody><!---ecms  插入新行的区域 end --></table><div align="center" style="margin:10px"><!---ecms --></div>

php部分

PHP code

$con = mysql_connect("localhost","root","mysql") or die ("连接数据库失败"); //数据库用户名及数据库密码    //数据库名称    mysql_select_db('BERecord');  //数据库名称     mysql_query('set names utf8');           //只有一行插入时的sql语句              $record=$_POST['record'];                //登记    //$no=$_POST['no'];                        //NO、    $usercode=$_POST['usercode'];            //用户号码    $buildname=$_POST['buildname'];            //建筑名称        for($i=0;$i<3;$i++){    $sql="insert into record(record,usercode,buildname) values('$record[$i]','$usercode[$i]','$buildname[$i]')";    $result=mysql_query($sql,$con);            if($result!= 0){        echo "数据插入成功";        echo "
";        echo "正在返回输入页面,跳转中...";        echo "<meta http-equiv='refresh' content='2;url=yanshi.php'>";      }        else    {        echo "插入数据失败";        echo mysql_error();    }    }


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:js动态添加行后,往数据库中插入数据的有关问题
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址