dsk49208 2013-01-14 08:05
浏览 91
已采纳

使用X-editable for Bootstrap将值发送到post.php

I use Twitter Bootstrap and decided to use X-editable with it. I put in all the necessary files and it works fine except that I want to pass values to post.php where I want PHP to process $_POST["value"].

Markup of the editable element is

<a href="#" id="example">Example</a>

I call it like this

$(function() {
  $.fn.editable.defaults.mode = 'inline';

  $('#example').editable({
  type: 'text',
  pk: 1,
  url: 'post.php',
  title: 'Enter example'
   });
});

I used jEditable as an inline editor in which I passed on values to a php file with no problems and I would like to do so with X-editable but I can't seem to do it.

How do I pass the values to post.php so I can use php to manipulate the data?

  • 写回答

2条回答 默认 最新

  • drbd65446 2014-03-08 13:46
    关注

    <a href="#" id="example">Example</a>

    you must add data-name=""

    <a href="#" id="example" data-name="db-col-name">Example</a>

    so when you access it in post.php, you can do like this:

    $name = $_POST['name'] // $_POST['name'] catches the data-name value

    $pk= $_POST['pk'] // the pk(primary key) that you assigned

    $value= $_POST['value'] // the new value after you use the inline edit

    after that you could do something like this

    if(!empty($value)) {

    $result = mysql_query('update users set '.mysql_escape_string($name).'="'.mysql_escape_string($value).'" where user_id = "'.mysql_escape_string($pk).'"');

    } else {
        header('HTTP 400 Bad Request', true, 400);
        echo "This field is required!";
    } `
    

    credits to the makers of x-editable its from their php sample more info here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容