hi im looking for a MPTT (modified pre-order tree transversal) script or a function class in php to help me retrieve a tree menu from mysql database. i was wondering if you can help me with the
wallpapers -animals -cats -lions -birds screensavers -fish -sharks -water -beaches -ocean categories -subcategory -subsubcategory
CREATE TABLE `mptt` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(50) NOT NULL default '',
`left` int(11) NOT NULL default '0',
`right` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
--
-- Dumping data for table `mptt`
--
INSERT INTO `mptt` VALUES (1, 'food', 1, 18);
INSERT INTO `mptt` VALUES (2, 'fruit', 2, 11);
INSERT INTO `mptt` VALUES (3, 'meat', 12, 17);
INSERT INTO `mptt` VALUES (4, 'red', 3, 6);
INSERT INTO `mptt` VALUES (5, 'yellow', 7, 10);
INSERT INTO `mptt` VALUES (6, 'beef', 13, 14);
INSERT INTO `mptt` VALUES (7, 'pork', 15, 16);
INSERT INTO `mptt` VALUES (8, 'cherry', 4, 5);
INSERT INTO `mptt` VALUES (9, 'banana', 8, 9);
<?
$db = mysql_connect("HOSTNAME", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE_NAME",$db);
$sql = "SELECT title FROM mptt WHERE `left` BETWEEN 2 AND 11";
$result = mysql_query($sql ,$db);
if ($myrow = mysql_fetch_array($result)) {
do {
echo $myrow['title'].'<BR>';
} while ($myrow = mysql_fetch_array($result));
}else{
echo '<strong>ERROR: </strong>'.mysql_error();
}
?>
Joe Celko Nested Sets nested, nested sets
www.phpclasses.org/browse/package/1374.html
https://www.webune.com/forums/mptt-modified-pre-order-tree-transversal-php-tree-menu-script-t5713.html