Jump to content

Update query to switch the values of 2 table rows PHP Mysql


sngumo

Recommended Posts

Hi

 

I have been frustrated trying to create a function or MySql query which will switch the values (same table column) of 2 rows in the same table.

 

Here is the code

 

***********************************************

connect();

 

$location = $_GET['location'];

$old_position = $_GET['oldpos'];

$new_position = $_GET['newpos'];

 

$move[0] = "UPDATE menu SET menu_order = '$old_position' WHERE menu_order = '$new_position' AND accesslevel = '$location'";

$move[1] = "UPDATE menu SET menu_order = '$new_position' WHERE menu_order = '$old_position' AND accesslevel = '$location'";

 

for($i=0;$i<=1;$i++)

{

mysql_query($move[$i]);

}

**********************************************

 

Once I run the code it only performs the first query.

 

 

Please I need your assistance

 

Thanx

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.