English 中文(简体)
如何将图片在jquery/php/mysql中按照谷歌Picasa重新排序界面进行排序?
原标题:How to sort images in jquery/php/mysql same as google picassa reorder interface?

我正在使用 PHP/MYSQL。

我想为打造图像创造形象。 用户将挖掘和播下图像,以整理和组织图像。 就像红灯一样。

我使用jQuery UI sortable插件创建了一个页面:http://jqueryui.com/demos/sortable/#display-grid

演示页面:http://jsbin.com/oqani/9/

它可以正确地拖放图像。但是,用户完成对图像的排序后,我无法获得图像的当前顺序。一旦我得到了当前顺序,我就必须将该顺序保存到该特定图像的数据库中。

附录 我的图像如下:1、2、3、4、5、6、7、8、9,然后,我照搬图像和顺序改为1、3、4、7、8、2、5、6、9。 因此,在点击“Show Order”时,它应当把命令显示为1、3、4、7、8、2、5、6、9

请问有人能帮我显示“显示顺序”按钮的当前图片顺序,并提供有关如何将特定图片的当前顺序放入数据库的概念吗?

谢谢 (Xièxiè)

最佳回答

是的,实际上,在jQuery UI中有一些事件,如updatestart等,使用它们我们可以获取新的排序顺序。

这是最终的工作演示:http://jsbin.com/oqani/10/

问题回答
jQuery("#contentSortableUL").sortable({
    opacity: 0.6,
    cursor: "move",
    update: function(){
        var order = $(this).sortable("serialize"); 
        jQuery.post("update-sorting.php", order, function(theResponse){
            // Callback code here
        });
    }
});

要更新数据库,您需要在update-sorting.php页面中编写代码:

<?php
/* code in update-sort.php would look like */
include("includes/db.connection.php");

$updateRecordsArray = $_POST[ recordsArray ];
$listingCounter = 1;
$orderedImageIds = array();

foreach ($updateRecordsArray as $recordIDValue){
    $listingCounter = $listingCounter + 1;

    /* update query goes here */
    update tableName set order = $listingCounter 
}
?>

希望这有所帮助。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签