Jump to content


Photo

problem with a function to change order of items


  • Please log in to reply
1 reply to this topic

#1 spyke01

spyke01
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 24 July 2006 - 07:05 AM

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:
		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);
		}
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?

[a href="http://www.fasttracksites.com" target="_blank"]Cheap PHP Hosting[/a]

#2 spyke01

spyke01
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 24 July 2006 - 07:22 PM

bump, still need help guys

[a href="http://www.fasttracksites.com" target="_blank"]Cheap PHP Hosting[/a]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users