当我单击第二行中的插入链接时,它会传递第一行的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-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>
弹出窗口:
<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> </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">
模型: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');
}
在form_open('money_c/manualupdatesave/'.$id)
中,我只获得第一行ID,而不是第二行的ID。
答案 0 :(得分:0)
<a href="#pop" >Insert<div id="pop" class="box">
将此行更改为
<a href="#pop-<?php echo $id;?>" >Insert<div id="pop" class="box">
你弹出的代码仍然不完整(假设它应该是这样的)
<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> </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">