Search code examples
phpmysqlyui

Using YUI3 how do I update a record in Mysql?


I have built a drag and drop interface which reads the list from a mysql dB. Now how can I save the "sort order" back to an id? I have a PHP function that will do the saving but I am a notice with YUI and need a Javascript function to call this PHP function to update a record.

This is what I copied to build the drag and drop. http://developer.yahoo.com/yui/3/examples/dd/list-drag.html

Any help is appreciated.


Solution

  • In order to update a record, what you need to do is making an ajax xmlHtppRequest so that it can make an HTTP POST request and have the data be passed into your server side language. In the end, your server side language will update the record by adding that data into your existing record..it will be something in this form:

    YUI().use("io-base", function(Y) {
        var cfg, request, uri; 
            uri = "ssPage.php" //The PHP page in which you pass the data to 
    
        cfg = {
            method: 'POST',  //you want a POST transaction
                data: 'user=yahoo',  //your data
            arguments: { 'foo' : 'bar' }
        };
    
        request = Y.io(uri, cfg);
    })
    

    I am not that familiar with YUI3, and all I can say is read the documentation of YUI3:IO from yahoo since it will help a lot. Hope that helps.