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 前端 uniapp App端在离线状态如何使用modbus 连接手机蓝牙进行读写操控机器?
  • ¥15 SQL语句根据字段自动生成行
  • ¥500 “掌声响起来”软件(不确定性人工智能)
  • ¥500 我要找大模型一体机产品手册和应用案例
  • ¥60 用r语言进行数据分析
  • ¥20 关于游戏c++语言代码问题
  • ¥15 如何制作永久二维码,最好是微信也可以扫开的。(相关搜索:管理系统)
  • ¥15 delphi indy cookie 有效期
  • ¥15 labelme打不开怎么办
  • ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏