===== jQuery UI sortable enables us to reorder the HTML element by drag & drop. ===== This will use to allow the users to adjust the positions of [[https://makitweb.com/make-photo-gallery-from-image-directory-with-php/|images]] to display on the webpage. In this tutorial, I show how you can [[https://makitweb.com/upload-and-store-an-image-in-the-database-with-php/|save]] the sorted image list order in the MySQL database and read it. \\ [[https://makitweb.com/demo/sortable/|Demo]] \\ {{programmieren:php:snippets:how-to-reorder-images-and-save-to-mysql-with-jquery-ajax.zip}} ---- ==== Contents ==== - [[#table_structure|Table structure]] - [[#configuration|Configuration]] - [[#html_php|HTML & PHP]] - [[#php|PHP]] - [[#script|Script]] - [[#conclusion|Conclusion]] ---- ===== 1. Table structure ===== I am using ''images_list'' table in the example. CREATE TABLE `images_list` ( `id` int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT, `name` varchar(150) NOT NULL, `location` varchar(150) NOT NULL, `sort` int(2) NOT NULL DEFAULT '0', `timemodified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ---- ===== 2. Configuration ===== Create a new ''config.php'' file. **Completed Code** ---- ===== 3. HTML & PHP ===== Use ''