gpt4 book ai didi

php - Zend Framework 1 更新操作

转载 作者:行者123 更新时间:2023-11-29 02:55:40 26 4
gpt4 key购买 nike

<分区>

我有一个非常烦人的问题。通过单击“更新”按钮,我总是得到相同的结果——只有最后一个元素被编辑。不幸的是我找不到解决方案。感谢您的帮助。

这是 View 部分:

<form id="edit-action" enctype="multipart/form-data" action="<?php echo $this->baseUrl; ?>/admin/editflight" method="post">
<?php
for ($i=0; $i < count($this->flight); $i++) {
echo "<div class='edit-action-box'>".
"<input type='hidden' name='id' value='".$this->flight[$i]->id."' />".
"<input type='text' name='name' value='".$this->flight[$i]->name."' />".
"<input type='text' name='date' value='".$this->flight[$i]->date."' />".
"<textarea name='description'>".$this->flight[$i]->description."</textarea>".
"<input id='edit-button' type='submit' value='Edit' />".
"</div>";
}
?>
</form>

这是 Controller 部分:

function editflightAction() {

if ($this->_request->isPost()) {
Zend_Loader::loadClass('Zend_Filter_StripTags');
$filter = new Zend_Filter_StripTags();
Zend_Loader::loadClass('flight');
$flight = new flight();

$id = (int)$this->_request->getPost('id');

$name = $filter->filter($this->_request->getPost('name'));
$name = trim($name);

$date = $filter->filter($this->_request->getPost('date'));
$date = trim($date);

$description = $filter->filter($this->_request->getPost('description'));
$description = trim($description);

$data = array(
'name' => $name,
'date' => $date,
'description' => $description,
);
$where = 'id = ' . $id;
$flight->update($data, $where);

$this->_redirect('/admin/panel#flight');
return;
}
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com