可编辑网格(ExtJS)使用PHP+;MySQL

可编辑网格(ExtJS)使用PHP+;MySQL,php,javascript,mysql,extjs,grid,Php,Javascript,Mysql,Extjs,Grid,我在理解将数据记录到MySQL数据库方面有点困难。现在,我的数据库中有一些表格显示在网格中。我附加了一个编辑器,但我不知道如何正确使用它(将可编辑数据发送到php脚本)。我可以寻求帮助吗? 谢谢 view.js Ext.onReady(function() { var cols = [ { dataIndex: 'id', header: 'id', hidden: true }, { dataIndex: 'title', header: 'Title', wi

我在理解将数据记录到MySQL数据库方面有点困难。现在,我的数据库中有一些表格显示在网格中。我附加了一个编辑器,但我不知道如何正确使用它(将可编辑数据发送到php脚本)。我可以寻求帮助吗? 谢谢

view.js

    Ext.onReady(function() {
    var cols = [
    { dataIndex: 'id', header: 'id', hidden: true },
    { dataIndex: 'title', header: 'Title', width: 200, editor: 'textfield'},
    { dataIndex: 'author', header: 'Author', width: 200, editor: 'textfield' },
    { dataIndex: 'isbn', header: 'ISBN', width: 100, editor: 'numberfield' },
],

    fields = [];
        for(var i=0; i<cols.length; i++) {
        fields.push(cols[i].dataIndex);
    }

Ext.define('Book', {
    extend: 'Ext.data.Model',
    fields: fields 
});

var store = Ext.create('Ext.data.JsonStore', {
    model: 'Book',
    proxy: {
        type: 'ajax',
        url: 'view.php',
        reader: {
            type: 'json'
        }
    }
});

Ext.create('Ext.grid.Panel', {
    columns: cols,
    width: 520,
    style: 'margin-top: 20%; margin-left: 35%',
    plugins: [
        Ext.create('Ext.grid.plugin.RowEditing', {
            clicksToEdit: 2
        })
    ],
    renderTo: Ext.getBody(),
    store: store
});
store.load();
});
    Ext.onReady(function(){
Ext.QuickTips.init();
var simpleForm = new Ext.FormPanel ({
    labelWidth: 75,     
    url:'edit.php',    
    frame:true,
    title: 'Add book',
    bodyStyle:'padding:5px 5px 0',
    width: 350,
    defaults: {width: 230},
    defaultType: 'textfield',

        items: [{
            fieldLabel: 'Title',
            name: 'title',
            allowBlank:false
            },{
            fieldLabel: 'Author',
            name: 'author'
            },{
            fieldLabel: 'ISBN',
            name: 'isbn'
        }],            
        buttons: [{
            text: 'Save',          
            handler: function () {
                simpleForm.getForm().submit({
                    waitMsg: 'Saving...',   
                    success: function () {     
                        Ext.MessageBox.alert ('Message','Data has been saved');
                        simpleForm.getForm().reset();
                    },
                  failure: function () {   
                        Ext.MessageBox.alert ('Message','Saving data failed');
                    }
                });
            }
        },{
            text: 'Cancel',
            handler: function () {
                simpleForm.getForm().reset();
            }
        }]
    });
    simpleForm.render ('simple-form');
});
edit.php-???

    <?php
    require_once 'db.php';
    $q=mysql_query ("INSERT INTO books VALUES (null, '".$_POST['title']."','".$_POST['author']."','".$_POST['isbn']."')
    ") or die ('{"success":"false"}');

    // json output to notify the insert is success or not
    if ($q) {
        echo '{"success":"true"}';
    }
    else {
        echo '{"success":"false"}';
    }
?>

您应该向提交功能添加url:字段您应该向提交功能添加url:字段
    <?php
    require_once 'db.php';
    $q=mysql_query ("INSERT INTO books VALUES (null, '".$_POST['title']."','".$_POST['author']."','".$_POST['isbn']."')
    ") or die ('{"success":"false"}');

    // json output to notify the insert is success or not
    if ($q) {
        echo '{"success":"true"}';
    }
    else {
        echo '{"success":"false"}';
    }
?>