php if isset _GET up mysql_result mysql_query SELECT COUNT FROM links_

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?php
if (isset($_GET['up']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `links_user` WHERE `id` = '". num($_GET['up']) ."' AND `id_user` = '$user[id]' LIMIT 1") ,0) == 0) {
$up = mysql_fetch_array(mysql_query("SELECT * FROM `links_user` WHERE `id` = '" . num($_GET['up']) . "' AND `id_user` = '$user[id]' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `links_user` WHERE `pos` < '$up[pos]' AND `id_user` = '$user[id]' LIMIT 1"),0)!=0) {
mysql_query("UPDATE `links_user` SET `pos` = '" . ($up['pos']) . "' WHERE `pos` = '" . ($up['pos'] - 1) . "' AND `id_user` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `links_user` SET `pos` = '" . ($up['pos'] - 1) . "' WHERE `id` = '" . num($_GET['up']) . "' AND `id_user` = '$user[id]' LIMIT 1");
}
}
if (isset($_GET['down']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `links_user` WHERE `id` = '". num($_GET['down']) ."' AND `id_user` = '$user[id]' LIMIT 1") ,0) == 0) {
$down = mysql_fetch_array(mysql_query("SELECT * FROM `links_user` WHERE `id` = '" . num($_GET['down']) . "' AND `id_user` = '$user[id]' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `links_user` WHERE `pos` > '$down[pos]' AND `id_user` = '$user[id]' LIMIT 1"),0)!=0) {
mysql_query("UPDATE `links_user` SET `pos` = '" . ($down['pos']) . "' WHERE `pos` = '" . ($down['pos'] + 1) . "' AND `id_user` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `links_user` SET `pos` = '" . ($down['pos'] + 1) . "' WHERE `id` = '" . num($_GET['down']) . "' AND `id_user` = '$user[id]' LIMIT 1");
}
}
?>