我如何编辑我的记录?我不断得到错误的页面。。谢谢提前真的需要帮助我的基础上我的代码在我的删除功能,我从昨天得到,但我没有运气这样做的编辑控制器
function update()
{
$booking=array(
'name'=>$this->input->post('name'),
'nationality'=>$this->input->post('nationality'),
'number_of_guest'=>$this->input->post('number_of_guest'),
'date'=>$this->input->post('date'),
'package'=>$this->input->post('package'),
'request'=>$this->input->post('request')
);
$this->site_model->update_record($booking);
$this->edit();
}
站点模型
function update_record($booking)
{
$this->db->where('id', 1);
$this->db->update('booking', $booking);
}
edit.php
<div id="bgbp"></div>
<div id="bp">
<h2 class="nb">Update</h2>
<?php echo form_open('site/update');?>
<div id="nems">
<p>
<label for="name"> Guest name(s): </label>
<input type="text" name="name" id="name" placeholder="Name(s)"/>
</p>
</div>
<div id="nat">
<p>
<label for="nationality">Nationality: </label>
<input type="text" name="nationality" id="nationality" placeholder="Nationality"/>
</p>
</div>
<div id="nog">
<p>
<label for="number_of_guest"> Number of Guest:</label>
<input type="number" name="number_of_guest" id="number_of_guest" placeholder="Number of Guest"/>
</p>
</div>
<div id="doa">
<p>
<label for="date"> Date of Arrival:</label>
<input type="date" name="date" id="date"/>
</p>
</div>
<div id="mainselection">
<select name="package" id="input7">
<option value="" style="display:none">Choose Package to avail</option>
<option value="Package A. Half - day City Tour">Package A. Half - day City Tour</option>
...
<option value="Package B. Honda Bay Island Hopping">Package B. Honda Bay Island Hopping</option>
<option value="Package C. St. Paul's Subterranean River National Park or Underground River">Package C. St. Paul's Subterranean River National Park or Underground River</option>
</select>
</div>
<div id="or">
<p>
<label for="request"> Other Request: </label>
<input type="comment" name="request" id="request" placeholder="Other Request"/>
</p>
</div>
<div id="sub">
<p>
<input type="submit" value="Submit" onclick="msg()" />
</p>
</div>
<?php echo form_close();?>
我查看页面..(显示我的编辑和删除按钮)
<?php
$this->table->set_heading("Name","Nationality","Number of Guest","Date of Arrival","Package","Other Request","Delete Record","Edit");
$qry = $this->db->get('booking');
foreach ($qry->result() as $row) {
$this->table->add_row($row->name,$row->nationality,$row->number_of_guest,$row->date,$row->package,$row->request,anchor('site/delete/'.$row->id, 'Del'),anchor('site/update/'.$row->id, 'edit'));
}
echo $this->table->generate();
3条答案
按热度按时间r55awzrz1#
在CodeIgnitor中,可以通过给出对表中现有记录的引用来更新任何记录。
booking
应该是要更新的表,并且$booking
必须是包含字段名和值的键/值对的数组。检查表(
booking
)的字段名是否与$booking
中的键相同!!5w9g7ksd2#
你也可以这样试。
请运行该程序并将您得到的内容粘贴到
$error
中uyto3xhc3#
试试这个代码......这是我的代码,你可以根据你的要求修改。
检视
型号
主计长