( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
if($_POST['sortdata'])
{
echo "ffffffffffffffffff";// The data arrives as a comma-separated string,
// so we extract each post ids:
$data=explode(',',str_replace('li','',$_POST['sortdata']));
$sortuser = $_SESSION['euserid'];
// Getting the number of objects
list($tot_objects) = mysql_fetch_array(mysqli_query($link,"select COUNT(*) FROM gocart where topicid=$sortuser" ));
if(count($data)!=$tot_objects);
foreach($data as $k=>$v)
{
// Building the sql query:
$str[]='('.(int)$v.','.($tot_objects-$k).')';
}
$str = 'VALUES'.join(',',$str);
$sortuser = $_SESSION['euserid'];
mysqli_query('INSERT INTO `gocart` (id,positions) '.$str.' ON DUPLICATE KEY UPDATE positions = VALUES(positions)');
mysqli_query('DELETE FROM gocart WHERE topicid=0');
print $str;
}
if($_POST['sortrated'])
{
// The data arrives as a comma-separated string,
// so we extract each post ids:
$data=explode(',',str_replace('li','',$_POST['sortrated']));
$sortuser = $_SESSION['euserid'];
// Getting the number of objects
list($tot_objects) = mysql_fetch_array(mysqli_query($link,"select COUNT(*) FROM ratedilike where topicidr=$sortuser"));
if(count($data)!=$tot_objects) ;
foreach($data as $k=>$v)
{
// Building the sql query:
$str[]='('.(int)$v.','.($tot_objects-$k).')';
}
$str = 'VALUES'.join(',',$str);
mysqli_query('INSERT INTO `ratedilike` (rid,positions) '.$str.' ON DUPLICATE KEY UPDATE positions = VALUES(positions)');
mysqli_query('DELETE FROM ratedilike WHERE topicid=0');
}
?>