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");
    
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services