Jump to content

Dragging a Div...


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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.