Jump to content

Dragging a Div...


Go to solution Solved by Kristoff1875,

Recommended Posts

I've found this http://www.elated.com/res/File/articles/development/javascript/jquery/drag-and-drop-with-jquery-your-essential-guide/card-game.html which is very similar to what I want to do, however the DIV's used as code are generated in the jquery that I'm not too sure how to change to make it work how I want. Does anyone have any idea how I could pre populate these divs with a search in a MYSQL table instead and echo it as my foreach row statement?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/278042-dragging-a-div/
Share on other sites

The bit I don't really understand:

 // Create the pile of shuffled cards
  var numbers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
  numbers.sort( function() { return Math.random() - .5 } );

  for ( var i=0; i<10; i++ ) {
    $('<div>' + numbers[i] + '</div>').data( 'number', numbers[i] ).attr( 'id', 'card'+numbers[i] ).appendTo( '#cardPile' ).draggable( {
      containment: '#content',
      stack: '#cardPile div',
      cursor: 'move',
      revert: true
    } );
  }

And I was hoping in some way I could say something like:

$result = mysql_query($query);

echo "<div id='card". $row['CardID'] ."'>". $row['CardName'] . "</div>";

To show all the cards from a table with the ID's and names stored in the table.

Edited by Kristoff1875
Link to comment
https://forums.phpfreaks.com/topic/278042-dragging-a-div/#findComment-1430306
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.