I need help with trying to re-order menus. The script begins with multiple menus that have weights. When i re-order the catagorys it displays them by weight, and when you edit the weight you change The order its placed from top to bottom. I want to make them all edit at once instead of having to seperatly edit them. This same method is employed in Invisions (a discussion board) Board, and catagory re-order function in the admin CP.
I've made the first part, but I dont really know how to script the Save part of the script.
function orderblock($s) { //varible $s is the side, for modifying the weight of the right or left sides. (they are completely different
global $defaultlayout, $s, $http, $DB; //the varible $DB is required to work with multiple database types (its also an object)
$s = $_GET['s'];
is_admin2(); //to check whether he's admin
include ("header.php");
tabletop();
echo "<center><b><font size='3' class='title'><a href='index.php?index=adm&admin=viewadminmenu'>Administrative Control Panel</a></b></center>\n" //html form begins here
."<center><b><font size='2' class='title'>Blocks Administration (Re-order)</b></center>\n"
.""._ADMINBLOCKS."\n"
."<table width='100%' cellpaddding='0' cellspacing='0' border='1'>\n"
." <tr>\n"
." <td width='40%' valign='top'><font size='1' class='content'>Name</td>\n"
." <td width='60%' valign='top'><font size='1' class='content'>Order</td>\n"
." </tr>\n";
$result = $DB->query ("SELECT * FROM menu WHERE side='$s' ORDER BY weight");
$i = 0;
while ($order = $DB->getrow ($result)) { //heres where the multiple form inputs are produced
IF ($order[4]==0) {
echo " <tr>\n"
." <td width='40%' valign='top'><font size='1' class='content'>$order[1]</td>\n"
." <td width='60%' valign='top'><font size='1' class='content'><input type='text' name='order[$i]' value='$order[3]' style='border:#000000 1px solid;background-image: url([url]http://[/url]$http/images/forms/formbg.gif); background-repeat: no-repeat;'></td>\n"
." </tr>\n";
} ELSE {
$rest = $DB->query ("SELECT * FROM menufunc WHERE id='$order[4]'"); //there is menu functions aswell as normal text menus that need modifying in weight
$or = $DB->getrow ($rest);
echo " <tr>\n"
." <td width='40%' valign='top'><font size='1' class='content'>$or[1]</td>\n"
." <td width='60%' valign='top'><font size='1' class='content'><input type='text' name='order[$i]' value='$order[3]' style='border:#000000 1px solid;background-image: url([url]http://[/url]$http/images/forms/formbg.gif); background-repeat: no-repeat;'></td>\n"
." </tr>\n";
$i++;
}
}
$DB->free ($result);
echo "</table><br><center><b>[ <a href='index.php?index=adm&admin=blocks'>Return To Menus Overview</a> ]<b></center>\n";
tablebottom();
include ("footer.php");
}
If you need to make any modifications to this inorder to make it work for the save then please go right ahead.
Oh and before I forget heres the SQL table structure
CREATE TABLE menu (
id int(25) NOT NULL auto_increment,
title tinytext NOT NULL,
body text NOT NULL,
weight tinyint(20) NOT NULL default '0',
function tinyint(40) NOT NULL default '0',
side tinytext NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;