rearranging records in backend cms via the use of and up/down arrow
Hi I wondered if you could help adjusting some code to work with MySQLi and WebAssist code. Basically I had a restaurant menu and in the backend i want to allow the client to change the order of the various menu items (so I am populating the field itemorderid).The client will be able to reorder the menu items via a small up and down arrow icon link that will be show up on every record on the admin page.
So what I will be doing is coding the backend so that when the client clicks on the up or down arrow icon it will append the url with a url variable that I can then use in an IF statement to check with.
I found some php code, I just need to adjust it to work with mysqi updates:
if (isset($_GET['move']) )
{
if ( $_GET['move'] == "up")
{
$connector->query("UPDATE `TopTips` SET `order` = `order` - 1 WHERE `id` = " . $_GET['lastid']);
$connector->query("UPDATE `TopTips` SET `order` = `order` + 1 WHERE `id` = " . $_GET['id']);
}
else if ( $_GET['move'] == "down")
{
$connector->query("UPDATE `TopTips` SET `order` = `order` + 1 WHERE `order` = " . $_GET['nextid']);
$connector->query("UPDATE `TopTips` SET `order` = `order` - 1 WHERE `id` = " . $_GET['id']);
}
}