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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?