// 控制器:ctrl_edit.php
class ctrl_edit extends CI_Controller {
public function index($code)
{
$this->load->database();
$sql = "select code, name from warehouse_type where code = " . $code;
$query = $this->db->query($sql);
$res['data'] = $query->result_array();
$this->load->view('wh_type/view_edit', $res);
}
public function edit()
{
$code = $this->input->post('code');
$name = $this->input->post('name');
$sql = "update warehouse_type set name = '" . $name . "' where code = " . $code;
echo $sql;
exit;
}
}
// 视图:view_edit.php
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<script type="text/javascript">
function edit() {
frm.submit();
window.opener.location.reload();
}
</script>
</head>
<body>
<table border="0" cellpadding="4" cellspacing="0">
<form name="frm" action="ctrl_edit/edit" method="post">
<tbody>
<tr>
<td align="right">代码:</td>
<td align="left">
<input type="text" id="code" name="code" value="<?php echo $data[0]['code'] ?>" readonly></input>
</td>
</tr>
<tr>
<td align="right">名称:</td>
<td align="left">
<input type="text" id="name" name="name" value="<?php echo $data[0]['name'] ?>"></input>
</td>
</tr>
<tr>
<td colspan="2" align="middle">
<input type="button" id="btn_ok" name="btn_ok" value="确定"></input>
</td>
</tr>
</tbody>
</form>
</table>
</body>
</html>