我有一个列表 每行都有一个存储在MySQL数据库中的公共输入字段“sort_order”。更改列表排序顺序内联
<input name="sort_order" type="text" value="<?php echo $cat['sort_order']; ?>" size="3" />
我希望能够在没有进入编辑窗体的情况下更改内联排序顺序。
如何获取数据库中的所有值。我想我需要遍历每行添加sort_order [row_id]和值到一个数组。但我坚持如何实现这一目标。
所有的值都根据firePHP发布。 SORT_ORDER [50]如图1所示,SORT_ORDER [51] 2等
在新解释尝试:
我有2个输入字段的列表视图。
<input name="cat_id" type="hidden" value="<?php echo $cat['cat_id']; ?>" />
<input name="sort_order" type="text" value="<?php echo $cat['sort_order']; ?>" size="3" />
我有这就是所谓的后上的控制器功能:
public function sortOrderUpdate(){
//collect the values of cat_id and sort_order from each input into a array
//$this->request->post['sort_order']
//$this->request->post['cat_id']
//send to the model
$this->model_cat->updateCatSortOrder($sortorderarray);
}
和数据库模型文件功能:
public function updateCatSortOrder($sortorderarray){
foreach((int)$sortorderarray as $sort){
$this->db->query("UPDATE cat SET sort_order='" . (int)$sort['sort_order'] . "' WHERE cat_id = '" . (int)$sort['cat_id'] . "'");
}
}
最新最好的方式实现这一目标?
你已经有一些代码保存在数据库中的值?看到你的数据库结构也会很有趣! – 2011-06-05 22:30:06
你能以某种方式清除你的问题吗?你在数据库中的领域是什么?你想要展示什么?对不起,我无法解决你的问题! – homayoun 2011-06-05 22:16:41
我有一个列表视图。我希望能够从列表视图编辑数据库中的'sort_order'列值。 – Steve 2011-06-05 22:24:07