我无法通过从弹出窗体中插入详细信息进行更新 [英] I cannot update by inserting details from a popup form

查看:79
本文介绍了我无法通过从弹出窗体中插入详细信息进行更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击第二行中的插入链接时,它会传递第一行的ID。只有第一列已更新。



我的控制器: money_c

  function addrow()
{
$ this-> load-> view('header');
$ this-> load-> view('manualupdate',$ result);
$ this-> load-> view('footer');
}

我的浏览页面: manualupdate.php

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd \"> 
< html xmlns =http://www.w3.org/1999/xhtml>
< head>

< / style> - >
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title>仅使用CSS的弹出式联系表单 - 演示| CodingCrazy< / title>
< link href =<?php echo base_url();?> assets / css / styleform.css =stylesheettype =text / css/>
< link href ='http://fonts.googleapis.com/css?family = Electrolize'rel ='stylesheet'type ='text / css'/>

<! - CC - >
< link rel =stylesheethref =<?php echo base_url();?> assets / css / fonts.css/>
< / head>

<! - < link rel =stylesheethref =<?php // echo base_url();?> assets / css / special.csstype =text / css/> - >
< div class =balstyle =margin-left:627px;
padding:15px;>

< table border =1>

< tr>
< th>日期< / th>
< th>说明< / th>
< th>类别< / th>
< th>借项< / th>
< th>信用< / th>
< th> Bal.AMT< / th>
< th> Insert< / th>
< th>编辑/删除< / th>< / tr>

<?php foreach($ query2 as $ row)
{

$ date = $ row-> date;
$ desc = $ row-> description;
$ credit = $ row-> credit;
$ deb = $ row-> debit;
$ bal = $ row-> bal;
$ cat = $ row-> category;
$ id = $ row-> id;

?>

< tr>< td><?php echo $ date;?>< / td>
< td><?php echo $ desc;?>< / td>
< td><?php echo $ credit;?>< / td>
< td><?php echo $ deb;?>< / td>
< td><?php echo $ bal;?>< / td>
< td><?php echo $ cat;?>< / td>

< td>< a href =#pop>插入< div id =popclass =box> //这里会弹出/// / pop up starts
< / tr>
<?php
}
?>< / table>

< / tbody>
< / table>

弹出式窗口:

 < div class =smart-green> 

<?php

echo
form_open('money_c / manualupdatesave /'.$ id)?>

< label>
< span>日期:< / span>
< input type =datename =dat/>
< / label>
< label>
< span>说明:< / span>
< input name =desctype =text/>
< / label>

< label>
< span>借记:< / span>
< input type =textname =deb>< / input>
< / label>
< label>
< span>信用:< / span>
< input type =textname =credit>< / input>
< / label>

< label>
< span>& nbsp;< / span>
< input type =submitstyle =margin-top:12pxclass =buttonstyle =background-color:#004e98;value =Send/>
< / label>
< / div>
<?php echo form_close();?> ////// pop up ends ///////////
<! - < / form> - >
< div id =close>

模型: money_m

 函数事务($ a,$ b,$ c,$ d,$ e,$ id)
{
$ this-> db-> where('id',$ id);
$ this-> db-> set('date',$ a);
$ this-> db-> set('description',$ b);
$ this-> db-> set('debit',$ d);
$ this-> db-> set('credit',$ e);
// $ data = array('date'=> $ a,'description'=> $ b,'debit'=> $ d,'credit'=> $ e);

$ this-> db-> update('manualupdate');

}

form_open('money_c /

解决方案

div>

 < a href =#pop> Insert< div id =popclass =box> 

将此行更改为

 < a href =#pop-<?php echo $ id;?> >插入< div id =popclass =box> 

您弹出的代码仍然不完整(假设它应该看起来像这样)

 < div id =#pop-<?php echo $ id;?>> 
<?php



echo
form_open('money_c / manualupdatesave /'.$ id)?>



< label>
< span>日期:< / span>
< input type =datename =dat/>
< / label>
< label>
< span>说明:< / span>
< input name =desctype =text/>
< / label>


< label>
< span>借记:< / span>
< input type =textname =deb>< / input>
< / label>
< label>
< span>信用:< / span>
< input type =textname =credit>< / input>
< / label>

< label>
< span>& nbsp;< / span>
< input type =submitstyle =margin-top:12pxclass =buttonstyle =background-color:#004e98;value =Send/>
< / label>
< / div>
<?php echo form_close();?> ////// pop up ends ///////////
<! - < / form> - >
< div id =close>


When I click the insert link in the second row it passes the ID of the first. Only the first row is updated.

My controller: money_c:

function addrow()
    {
        $this->load->view('header');
        $this->load->view('manualupdate',$result);
        $this->load->view('footer');
    }

My view page: manualupdate.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

        </style>-->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Popup contact form using only CSS - Demo | CodingCrazy</title>
    <link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/>
    <link href='http://fonts.googleapis.com/css?family=Electrolize' rel='stylesheet' type='text/css' />

    <!--CC-->
    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/fonts.css"/>
    </head>

    <!--<link rel="stylesheet" href="<?php // echo base_url();?>assets/css/special.css" type="text/css" />-->
    <div class="bal" style="margin-left: 627px;
        padding: 15px;">

    <table border="1">

        <tr>
                            <th>Date</th>
                   <th>Description</th>
                                  <th>Category</th>
                                  <th>Debit</th>
                                     <th>Credit</th>
                                        <th>Bal.AMT</th>
                                           <th>Insert</th>
                                           <th> EDit/Delete</th></tr>

               <?php foreach($query2 as $row)
               {

                   $date=$row->date;
                   $desc=$row->description;
                   $credit=$row->credit;
                   $deb=$row->debit;
                   $bal=$row->bal;
                   $cat=$row->category;
                   $id=$row->id;

              ?>

                    <tr><td><?php echo $date;?></td>
            <td><?php echo $desc;?></td>
            <td><?php echo $credit;?></td>
            <td><?php echo $deb;?></td>
            <td><?php echo $bal;?></td>
            <td><?php echo $cat;?></td>

           <td><a href="#pop" >Insert<div id="pop" class="box">////here pop up will come////pop up starts
</tr>
                    <?php
               }
               ?></table>

        </tbody>
    </table>

Popup:

<div class="smart-green">

    <?php

     echo
        form_open('money_c/manualupdatesave/'.$id)?>

            <label>
            <span>Date:</span>
            <input type="date" name="dat"  />
        </label>
          <label>
            <span>Description:</span>
            <input name="desc" type="text" />
        </label>

        <label>
            <span>Debit:</span>
            <input type="text" name="deb"></input>
        </label> 
         <label>
            <span>Credit:</span>
            <input type="text" name="credit"></input>
        </label> 

         <label>
            <span>&nbsp;</span>
            <input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" />
        </label>
        </div>
    <?php echo form_close();?>//////pop up ends///////////
    <!--</form>-->
    <div id="close">

model: money_m:

    function transaction($a,$b,$c,$d,$e,$id)
    {
        $this->db->where('id',$id);
        $this->db->set('date',$a);
        $this->db->set('description',$b);
        $this->db->set('debit',$d);
        $this->db->set('credit',$e);
//        $data=array('date'=>$a,'description'=>$b,'debit'=>$d,'credit'=>$e);

        $this->db->update('manualupdate');

    }

In form_open('money_c/manualupdatesave/'.$id) I get only the first row ID, not the ID of the second row.

解决方案

<a href="#pop" >Insert<div id="pop" class="box">

change this line to

<a href="#pop-<?php echo $id;?>" >Insert<div id="pop" class="box">

You you popup code is still not complete (assuming it should look like this)

<div id="#pop-<?php echo $id;?>">
 <?php 



     echo
        form_open('money_c/manualupdatesave/'.$id)?>



            <label>
            <span>Date:</span>
            <input type="date" name="dat"  />
        </label>
          <label>
            <span>Description:</span>
            <input name="desc" type="text" />
        </label>


        <label>
            <span>Debit:</span>
            <input type="text" name="deb"></input>
        </label> 
         <label>
            <span>Credit:</span>
            <input type="text" name="credit"></input>
        </label> 

         <label>
            <span>&nbsp;</span> 
            <input type="submit" style="margin-top:12px" class="button" style="background-color: #004e98;"value="Send" /> 
        </label>  
        </div>
    <?php echo form_close();?>//////pop up ends///////////
    <!--</form>-->
    <div id="close">

这篇关于我无法通过从弹出窗体中插入详细信息进行更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆