weixin_33725807 2013-07-04 13:32 采纳率: 0%
浏览 152

使用X-Editable-后端部分

So I'm just trying to use xeditable (http://vitalets.github.io/x-editable/docs.html#gettingstarted) to make changes to my database via AJAX. Since I'm new to this concept and I'm (forcefully) working with PHP for the first time, I need some help.

I setup the frontend part, and a script called (say) script.php is handling the data for me (I need to write the new value in my database).

I can't really understand what to do in the script. Can someone guide me towards it? The docs above don't really do it for me.

  • 写回答

1条回答 默认 最新

  • 关注

    Looking in a project I worked on a few months back (sorry about the mysql_ stuff – not my choice!)

    Something like:

    <?
    include your/database/connection_stuff.php;
    
    
    // Can't remember if x-editable passes the table in as well or not
    $table = mysql_real_escape_string($_GET['table']);
    // If not, 
    $table = 'name_of_table';
    
    
    $value = mysql_real_escape_string($_POST['value']);
    $name = mysql_real_escape_string($_POST['name']);
    $pk = mysql_real_escape_string($_POST['pk']);
    
    $result = mysql_query("UPDATE `$table` SET `$name` = '$value' WHERE id = '$pk'");
    
    ?>
    

    Will do the trick.

    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波