Jump to content

Recommended Posts

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=down

Does anyone see any problems with the code, or a simpler way of doing things?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.