我有兩個列表(1和2),並且我想在項目從一個移動到另一個時更新它們。JQuery UI可排序保存與連接列表
HTML:
<ul class="sortable" id="task-list">
<li id="listItem_1">Value 1 </li>
<li id="listItem_2">Value 2 </li>
<li id="listItem_3">Value 3 </li>
</ul>
<ul class="sortable" id="task-list-two">
<li id="listItem_4">Value 1 </li>
<li id="listItem_5">Value 2 </li>
<li id="listItem_6">Value 3 </li>
</ul>
JS:
$("#task-list, #task-list-two").sortable({
handle : '.handle',
connectWith: ".sortable"
update : function() {
var order = $('#task-list').sortable('serialize');
$("#info").load("process-sortable.php?"+order);
}
});
但我想更新列表(1或2)爲好。我是否需要向process.sortable.php
發佈其他變量?
我現在有在foreach只適用於第一個列表(簡體):
$task = nl2br($_POST['task']);
$userid = $_SESSION['userid'];
$position = $_POST['p'];
$date = $_POST['date'];
$i = "INSERT INTO tasks VALUES('','$task','$userid','0','$position','$date')";
$doi = mysql_query($i) or die(mysql_error());
提前感謝!
修訂FOREACH PHP:
foreach ($_GET['listItem'] as $position => $item)
{
$list = $_GET['list'];
if($list == "task-list")
{
$list = 1;
}
if($list == "task-list-two")
{
$list = 2;
}
$sql = "UPDATE `tasks` SET `position` = $position AND date = '$list' WHERE `id` = $item";
print($sql);
$dosql = mysql_query($sql) or die(mysql_error());
}
如果你正在做的是運行服務器端腳本,你可能should'nt使用負荷()? – adeneo
我這樣做是爲了檢索發佈的SQL語句。 – Andre
'list'參數從哪裏來? – daVe