我的提交表单存在问题。
这是我的控制器[offering_member]:
function offering_member {
$idTransaksi = $this->uri->segment(3); //$idTransaksi = 1
$data['anotheruser'] = $this->m_transaksi->getDataUserOffer($idTransaksi)->result(); //parameter $idTransaksi
$this->template_user->display('user/offeringbook/view_offeringbyuser', $data);
}
这是我的模型[getDataUserOffer]:
function getDataUserOffer($idTransaksi){ //$idTransaksi = 1
$this->db->select('*');
$this->db->from('tr_offer');
$this->db->select("DATE_FORMAT(tgl_gabung, '%b %d, %Y') AS tgl_gabung", FALSE);
$this->db->where('tr_offer.id_transaksi', $idTransaksi);
$this->db->join('user', 'user.id_user = tr_offer.id_user');
$query = $this->db->get();
return $query;
}
tr_offer table:
id_offer | id_transaksi | id_user | tgl_offer
1 | 1 | 7 | 2014-09-25
3 | 1 | 1 | 2014-09-28
这是我的观点[view_offeringbyuser.php]:
<?php $no=0; foreach($anotheruser as $row): $no++;?>
<form class="form-horizontal" action="<?php echo site_url('user/offermethod/'.$row->id_transaksi .'/'. $row->id_offer); ?>" method="post" />
<div>
<img src="<?php echo base_url ('assets/img/user/'.$row->foto); ?>" data-toggle="modal" data-target="<?php echo'#myModal'.$row->id_offer; ?>" alt="..." width="100" height="120">
</div>
<div>
<a href='<?php echo site_url('user/member/'.$row->username.'/');?>'><?php echo $row->username; ?></a>
<input type="text" class="form-control" name="<?php echo 'idOffer'.$no; ?>" value="<?php echo $row->id_offer; ?>">
</div>
<center>
<input name="hhh" value="<?php echo 'submit'. $no; ?>" type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-chevron-right"></i> </button>
</center>
</div>
<?php endforeach; ?>
此视图将显示:
> Photo[1] | Photo[2] ---> image
>
> ddd[1] | eee[2] ---> username
>
> 1 | 3 ---> input text value id_offer
>
> Submit1 [1] | Submit2 [2] ---> submit button form
当我点击Submit1时,操作将指向http:// 域 / user / offermethod / 1/1
但是当我点击Submit2时,也会直接转到http:// 域 / user / offermethod / 1 / 1 &lt;&lt;这应该是 3
我认为问题出在提交表单循环中。输入文本显示真值。但为什么操作形式只需设置 $ row-&gt; id_offer = 1 ,您点击提交2按钮的事件
我很抱歉我的英文不好,谢谢。
答案 0 :(得分:0)
您需要关闭表单
<?php $no=0; foreach($anotheruser as $row): $no++;?>
<form class="form-horizontal" action="<?php echo site_url('user/offermethod/'.$row->id_transaksi .'/'. $row->id_offer); ?>" method="post" />
<div>
<img src="<?php echo base_url ('assets/img/user/'.$row->foto); ?>" data-toggle="modal" data-target="<?php echo'#myModal'.$row->id_offer; ?>" alt="..." width="100" height="120">
</div>
<div>
<a href='<?php echo site_url('user/member/'.$row->username.'/');?>'><?php echo $row->username; ?></a>
<input type="text" class="form-control" name="<?php echo 'idOffer'.$no; ?>" value="<?php echo $row->id_offer; ?>">
</div>
<center>
<input name="hhh" value="<?php echo 'submit'. $no; ?>" type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-chevron-right"></i> </button>
</center>
</div>
<?php echo form_close(); ?> /* Close the form here */
<?php endforeach; ?>