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

  • Home
  • SEARCH
  • 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 5949375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:14:28+00:00 2026-05-22T17:14:28+00:00

Simple Version of my question: Is it possible to take a JQuery UI draggable

  • 0

Simple Version of my question:
Is it possible to take a JQuery UI draggable image’s ID, when it’s dropped into my goal droppable, and use the ID as a value and update a field in one of my MySQL database tables when the draggable image is dropped?

Technical Version of my question:
I used a tutorial from a website to make a drag and drop inventory feature for a game I am currently working on.

Anyways, I cannot give a direct link to my site, as it requires a login, and I haven’t gotten my system to work beyond my IP address, but here is what I am basically trying to do:

My drag and drop works great, but I need it to update a MySQL Database, I know for the tutorial I have linked, it has a second part that does it, but not the way I need.

So my user’s inventory has it’s own table with the following fields:

bid: this is the user id stored as a 32 digit unique random number
itemid: this is an 8 digit item code

All the information for the user and the objects are Inner Joined to combine the information into PHP Variables, I split these up over different tables because I have multiple sites that adjust each one. So far everything works here.

I use mysql_fetch_array() to load the items into the inventory box to make them draggable.

My items are formatted as so:

img src='$cheesepic' id='$itemid' class='object cheese'
$cheesepic == "http://motb.isgreat.org/objects/" . $itemid . ".png";

and $item id is stolen directly from the inventory table. The CSS classes object scales the image to my desired size, I like it better than thumbnails since it caches better because I use so many different sizes of the objects around the site. The cheese class is for dragging so it is only accepted by the cheese droppable.

Now I have another table in my database for the equipped objects. So the fields there are bid and cheese. I would like to be able to update my database with the ID of the image that was dragged into the droppable. And delete that row if they drag it out of the droppable and into the inventory droppable again.

Thanks for your help.

  • 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-05-22T17:14:29+00:00Added an answer on May 22, 2026 at 5:14 pm

    The jQuery Drag & Drop API let’s you get the data of the item being dragged, here’s an example of what you might be trying to do (data names and table row names are just random estimates):

    $(".inventory").droppable({
        drop: function(e, ui) {
            // This gets the ID of the item you are dragging
            var item_id = $(ui.draggable).attr('id');
    
            // Ajax call example...
            $.ajax({
                type: "GET",
                timeout: 10000,
                url: "http://example.com/item_update.php?item_id="+item_id,
            });
        }
    });
    

    The PHP/MySQL side of it is a bit harder to help you out with, seeing as most game scripts are really specific but you could do something along the lines of:

    $item_id = preg_replace( '/[^0-9]/', '', $_GET['id']);
    mysql_query("UPDATE user_items SET equipped = 0 WHERE item_id = ".$item_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Do I really need version control? My question is simple enough. When
Can someone please share a extremely simple version of JQuery Ajax with pagination??
Simple as the title states: Can you use only Java commands to take a
Simple question. Is it possible to add a block of HTML in a SimpleXMLElement
It is quite a simple question from me today. Is it possible to set
I use MySQL server version 5.5.14 and now I am trying this simple SQL
I am implementing a simple version of a linux shell in c. I have
the following is a very very simple version of malloc() and seems to allocate
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have a simple function written in Oracle 9i (version 9.2.0.4.0) to simulate an

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.