spyke01 Posted July 24, 2006 Share Posted July 24, 2006 ok im trying to be able to move forums, or other items for that matter, with simple PHP functions. The order of items is of course stored in the orders field of a table, the lower the value, the closer to the top of the list it is. I am using this function to do it, but sometimes it freaks out, usualy in IE(wierd though it is), and wont do anything, usually when this happens, the order is set to 999 and stays there.the code:[code] if ($_GET[action] == "moveforum") { $sql = "SELECT forum_order FROM `forums` WHERE forum_id='$_GET[id]' LIMIT 1"; $result = mysql_query($sql); if ($row = mysql_fetch_array($result)) { $current_order_num = $row[forum_order]; } mysql_free_result($result); if ($_GET[dir] == "up") { $target_order_num = ($current_order_num > 1) ? $current_order_num - 1 : 1; } else { $target_order_num = $current_order_num + 1; } $sql = "UPDATE `forums` SET forum_order='999' WHERE forum_id='$_GET[id]'"; $result = mysql_query($sql); $sql = "UPDATE `forums` SET forum_order='$current_order_num' WHERE (forum_order='$target_order_num' AND forum_cat_id='$_GET[catid]')"; $result = mysql_query($sql); $sql = "UPDATE `forums` SET forum_order='$target_order_num' WHERE forum_id='$_GET[id]'"; $result = mysql_query($sql); }[/code]the style of link that activates it index.php?action=moveforum&id=$forum_id&catid=$forum_cat_id&dir=downDoes anyone see any problems with the code, or a simpler way of doing things? Quote Link to comment https://forums.phpfreaks.com/topic/15454-problem-with-a-function-to-change-order-of-items/ Share on other sites More sharing options...
spyke01 Posted July 24, 2006 Author Share Posted July 24, 2006 bump, still need help guys Quote Link to comment https://forums.phpfreaks.com/topic/15454-problem-with-a-function-to-change-order-of-items/#findComment-63088 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.