Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:37:19+00:00 2026-06-09T08:37:19+00:00

I’m using jQuery UI to create a drag and drop function for a UL.

  • 0

I’m using jQuery UI to create a drag and drop function for a UL. The idea is that you can sort items within a list and the view order will update in the database (which is working). The function I’m trying to add now, is the ability to drag a LI into a different UL and have the database update so that the app knows which list the LI goes in. The item can be moved into a different list, but the php file I post to is not updating the database.

The PHP file echos the list like so:

<div class="list_div">
    <h3>List #1</h3>
    <ul id="listnumber_25" class="ui-sortable" unselectable="on">
        <li id="item_134">list item 1</li>
        <li id="item_135">list item 2</li>
        <li id="item_136">list item 3</li>
        <li id="item_137">list item 4</li>
    </ul>
</div>
<div class="list_div">
    <h3>List #2</h3>
    <ul id="listnumber_26" class="ui-sortable" unselectable="on">
        <li id="item_138">list item 1</li>
        <li id="item_139">list item 2</li>
        <li id="item_140">list item 3</li>
        <li id="item_141">list item 4</li>
    </ul>
</div>

And the JS looks like this:

//sort / change list
$(document).ready(function(){
    $(".list_div ul").sortable({
        receive: function(event, ui) {
            var list_id = this.id;
            var li_to_reassign = ui.item.attr('id');
            $.post("functions/changelist.php", { li_to_reassign: li_to_reassign, list_id: list_id } );
        }
    });
});

functions/changelist.php:

<?

$list_id = $_POST['list_id'];
$list_id = substr('$list_id', 11); 

$li_to_reassign = $_POST['li_to_reassign'];
$li_to_reassign = substr('$li_to_reassign', 5); 

//------------------------------------------

// connect to DB
$host="localhost"; // Host name 
$username="********"; // Mysql username 
$password="********"; // Mysql password 
$db_name="**********"; // Database name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="UPDATE tasks SET list_id='$list_id' WHERE id='$li_to_reassign'";
$result=mysql_query($sql);

?>

I can’t seem to find the problem!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:37:24+00:00Added an answer on June 9, 2026 at 8:37 am

    in your php file you’re getting the value from $_POST but straight after you reassing those variables with new value, using a variable $str that it’s not even set:

    $list_id = $_POST['list_id'];
    $list_id = $list_id($str, 11); 
    
    $li_to_reassign = $_POST['li_to_reassign'];
    $li_to_reassign = $li_to_reassign($str, 5); 
    

    it should be:

    $list_id = $_POST['list_id'];
    
    $li_to_reassign = $_POST['li_to_reassign'];
    

    EDIT (if you want to get a subtring of the $_POST variables use the function substr like this):

    $list_id = $_POST['list_id'];
    $list_id = substr($list_id, 11); 
    
    $li_to_reassign = $_POST['li_to_reassign'];
    $li_to_reassign = substr($li_to_reassign, 5); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.