title: jquery sortable and serialize in database?
body: <p>I am close to finishing this but am stuck at how to get the values out of the database and display the <code>&lt;li&gt;&lt;/li&gt;</code> in the correct order with the correct link.</p>
  
  <p>So far I have this:</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>    &lt;ul id="navMenu"&gt;
      &lt;li id="navMenu_1"&gt;&lt;a href="http://www.example.com/home"&gt;Your Home&lt;/a&gt;&lt;/li&gt;
      &lt;li id="navMenu_2"&gt;&lt;a href="#"&gt;Preferences&lt;/a&gt;&lt;/li&gt;
      &lt;li id="navMenu_3"&gt;&lt;a href="#"&gt;Your Mailbox&lt;/a&gt;&lt;/li&gt;
      &lt;li id="navMenu_4"&gt;&lt;a href="#"&gt;Game Updates&lt;/a&gt;&lt;/li&gt;
      &lt;li id="navMenu_5"&gt;&lt;a href="#"&gt;Message Boards&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>$('#navMenu').sortable({
  
  opacity: '0.8',
  containment: '#navMenu',
  cursor: 'move',
  revert: true,
  tolerance: 'pointer',
  align: 'y',
  update: function() {
      $.ajax({data: {navMenuLayout: $('#navMenu').sortable('serialize')}});
  }
  });
  </code></pre>
  
  <p><strong>AJAX PHP</strong></p>
  
  <pre><code>if (isset($_REQUEST['navMenuLayout'])) {
  
  session_start();
  $q = $dbc -&gt; prepare("UPDATE layout SET navMenu = ? WHERE id = ?");
  $q -&gt; execute(array($_REQUEST['navMenuLayout'], $_SESSION['id']));
  }
  </code></pre>
  
  <p>Everything works and I get a string like this saved into my database, when a user changes the order of the list.</p>
  
  <pre><code>navMenu[]=3&amp;navMenu[]=1&amp;navMenu[]=5&amp;navMenu[]=2&amp;navMenu[]=4
  </code></pre>
  
  <p>From having this in the database how can I then get php to echo the html above in the correct order, with the correct text showing for each link?</p>