Kristoff1875 Posted May 15, 2013 Share Posted May 15, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/278042-dragging-a-div/ Share on other sites More sharing options...
Irate Posted May 15, 2013 Share Posted May 15, 2013 What part do you not understand about the jQuery and how do you think this could work with MySQL? Quote Link to comment https://forums.phpfreaks.com/topic/278042-dragging-a-div/#findComment-1430303 Share on other sites More sharing options...
Kristoff1875 Posted May 15, 2013 Author Share Posted May 15, 2013 (edited) 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 May 15, 2013 by Kristoff1875 Quote Link to comment https://forums.phpfreaks.com/topic/278042-dragging-a-div/#findComment-1430306 Share on other sites More sharing options...
Solution Kristoff1875 Posted May 15, 2013 Author Solution Share Posted May 15, 2013 Ignore this now, think i've found a solution with a completely different code! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/278042-dragging-a-div/#findComment-1430309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.