dongpa2000 2014-06-26 09:34
浏览 71
已采纳

在jqgrid中添加,编辑和删除使用CodeIgniter反映在数据库中的数据

As with other questions, Oleg's assistance with jqgrid-related queries are very much helpful and appreciated. Through his answers I have been able to inch towards my goal; though what's bothering me is the editurl property. On most demos it's just someurl.php.

Oleg also said that this php file contains the instructions(mysql) to edit the database using data sent to it by jqgrid. By using Firebug I've seen that it is indeed posting the data entered but it results to Error 404 all the time. I've tried placing the someurl.php everywhere in the CI folder. And given that, I'm still not sure what to write in the someurl.php.

Can anyone please help? I've been stuck on implementing Add, Edit, and Delete the whole day.

  • 写回答

1条回答 默认 最新

  • dpauxqt1281 2014-07-02 08:52
    关注

    Thanks to the suggestion of Ballantine, I finally solved this.

    It turns out that someurl.php is indeed relative to index.php and is thus found at the controllers folder via CodeIgniter.

    From there, it's just a matter of using someurl.php as a controller:

    Here I took advantage of using the POST sent from the view page that contains jqGrid. They are the oper, clientCode, clientName, and id in my case.

    Furthermore, on the query part, I could've used something like $this->db->update via CodeIgniter but I since I'm a beginner at mySQL, I might as well try to familiarize myself with the syntax.

    And from here on, you could continue nesting this for the add and delete cases. I hope this helps someone!

    else if($_POST["oper"] == 'edit'){
    
    
            $newCode = $_POST["clientCode"];
            $newName = $_POST["clientName"];
            $id = $_POST["id"];
    
    
    
            $this->db->query("UPDATE tblclient SET clientCode = '$newCode', clientName = '$newName' WHERE clientCode = '$id' LIMIT 1");
    
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析