title: Drag, Drop, Swap, Mysql
body: <p>I read a lot of topics similar to this, but none that work with MySql database (except for sorting example )</p>
  
  <p>Here's an example that I was able to implement in my script (soccer manager)
  <a href="http://jsfiddle.net/k9854/" rel="nofollow">http://jsfiddle.net/k9854/</a></p>
  
  <pre><code>jQuery.fn.swap = function(b){ 
      // method from: http://blog.pengoworks.com/index.cfm/2008/9/24/A-quick-and-dirty-swap-method-for-jQuery
      b = jQuery(b)[0]; 
      var a = this[0]; 
      var t = a.parentNode.insertBefore(document.createTextNode(''), a); 
      b.parentNode.insertBefore(a, b); 
      t.parentNode.insertBefore(b, t); 
      t.parentNode.removeChild(t); 
      return this; 
  };
  
  
  $( ".dragdrop" ).draggable({ revert: true, helper: "clone" });
  
  $( ".dragdrop" ).droppable({
      accept: ".dragdrop",
      activeClass: "ui-state-hover",
      hoverClass: "ui-state-active",
      drop: function( event, ui ) {
  
          var draggable = ui.draggable, droppable = $(this),
              dragPos = draggable.position(), dropPos = droppable.position();
  
          draggable.css({
              left: dropPos.left+'px',
              top: dropPos.top+'px'
          });
  
          droppable.css({
              left: dragPos.left+'px',
              top: dragPos.top+'px'
          });
          draggable.swap(droppable);
      }
  });
  </code></pre>
  
  <p>all is greate, when i change player (Drag, drop and swap), but, when i refresh page, my new player ordering is lost.</p>
  
  <p>how to use this example with mysql database?
  or
  Is there any example that works with mysql database?</p>
  
  <p>thanks</p>