...

View Full Version : dtree menu help



eric float
07-16-2008, 07:22 PM
hi ! i need to any code for dtree menu for dynamic data view as php/mysql database . exp :
ID1
1
2
3
ID2
1
2
3
. . . . . . . note : add one category in admin panel so add in dtree menu . thanks . regards

ninnypants
07-17-2008, 04:10 AM
Are you trying to pull the info out of database and print it to the page?

p4plus2
07-17-2008, 06:19 AM
heres a on the fly script no guarantees for safty or usabilities....USE FOR A EXAMPLE ONLY


<?php
session_start();
require('config.php'); //set that up yourself should not be to hard.
/*
As of this point forward I am running under the impression, that you are using a login system already that has moderator, administrator, guest, and normal users written out in 'long' form naming. I am also assuming that sessions are used.
*/
$userlevel = $_SESSION['user_level'];
$permissions = array(administrator => array('add_tab', 'add_item', 'edit_tab', 'edit_item', 'delete_tab', 'delete_item', 'view'), moderator => array('add_item', 'edit_item', 'delete_item', 'view'), normal => array('view'), guest => array('view')); //one long array right there O.o
for($i = 0; $i <= count($permissions[$userlevel]); $i++){
switch($permission[$userlevel][$i]){
case('add_tab'):
echo("<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
break;
case('add_item'):
echo("<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
break;
case('edit_tab'):
echo("<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
break;
case('edit_item'):
echo("<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
break;
case('delete_tab'):
echo("<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
break;
case('delete_item'):
echo("<a href=\"menu.php?mode=$permissions[$userlevel][$i]\">$permission[$userlevel][$i]</a>");
break;
case('view'):
$view = true;
break;
default:
die('unknown condition');
break;
}
}
if(isset($_GET['mode'])){
$mode = $_GET['mode'];
if(!in_array($permissions[$userlevel])){
die('incorect permissions');
}
else{
echo('put the tab name or item name you want here<br />');
echo("<form action=\"menu.php?mode=$mode&step=2\" action=\"post\">");
echo('<input type="textbox" name="name" value="name goes here" />');
echo('<input type="submit" />');
echo('</form><br /><br /><br />');
echo('or if you are editing a item use this form here');
echo("<form action=\"menu.php?mode=$mode&step=2\" action=\"post\">");
echo('<input type="textbox" name="name" value="old name goes here" />');
echo('<input type="textbox" name="nametwo" value="new name here" />');
echo('<input type="submit" />');
echo('</form>');
}
}
if($_GET['step'] == 2 && isset($_GET['mode']) && isset($_POST['name'])){
$name = $_POST['name'];
$nametwo = $_POST['nametwo'];
if($mode == 'add_tab' || $mode == 'edit_tab' || $mode == 'delete_tab'){
$type = 'tab';
}
elseif($mode == 'add_item' || $mode == 'edit_item' || $mode == 'delete_item'){
$type = 'item';
}
if(!in_array($permissions[$userlevel])){
die('incorect permissions');
}
if($mode == 'add_tab' || $mode == 'add_item'){
mysql_query("INSERT INTO menu (type, name) VALUES('$type', '$name' ) ") or die(mysql_error());
}
elseif($mode == 'edit_tab' || $mode == 'edit_item'){
mysql_query("UPDATE menu SET name='$nametwo' WHERE type='$type' AND name='$name' ) ") or die(mysql_error());
}
elseif($mode == 'delete_tab' || $mode == 'delete_item'){
mysql_query("DELETE FROM menu WHERE type='$type' AND name='$name' ) ") or die(mysql_error());
}
echo('operation successfull');
}
?>


YOU MUST STILL MAKE THE PART TO GENERATE THE MENU THIS WILL ONLY MANAGE THE MENU.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum