:: CodeThat. Do IT this way! :: Free javascript menu, javascript tree, dhtml menu, dhtml tree, popup menu, outlook bar menu, free scripts, free javascript, calendar

PRODUCTS

JavaScript Projects

PHP Projects

Javascript Tools

SUPPORT

Standard vs PRO

FAQ

Contacts

Site Map

CODETHAT

Downloads

Users Testimonials

Our Customers

STUDIO   GRID   TABLE   MENU   TREE   XPBAR   HINT   EDITOR   TAB   FORM   CALENDAR   SCROLLER   SHOPPINGCART   TREEPHP   PACKER

Information

Introduction   PHP sample   CSS example

Order PRO Now

CODETHATTREEPHP - TEST.PHP

 

<php
require ("ct_tree_lite.php");
/* declare some relevant variables */
$hostname = "localhost"; /* This is the hostname on which your MySQL is running */
$dbName = "ct";
$username = "root";
$password = "";
/* Make connection to database */
mysql_connect($hostname, $username, $password) OR DIE("Unable to connect to database");
/* Select the database to be processed */
@mysql_select_db( "$dbName") or die( "Unable to select database");
Function ReadLevel($id, $level = 0)
{
	$str = "";
	/* Prepare and execute the SQL query statement */
	$query = "SELECT node_id, node_parent, node_name" .
		" FROM tree_nodes WHERE node_parent=" . $id;
	$result = mysql_query($query);
	/* Loop on results */
	while (list($node_id, $node_parent, $node_name) = mysql_fetch_row($result))
	{
		$subitems = ReadLevel($node_id, $level + 1);
		$str .= CreateItem(
			$node_id, // Id of the node, used for identification
			$node_name, // Name of the node
			            // (may be some html code),
			            // will be displayed
			"#", // URL
			"", // URL target
			$subitems == "" ? "clsItem" : "clsFolder", // CSS
			$subitems, // subitems string
			$level // level of the item for proper offset
		);
	}
	return ($str);
}
?> 

<html>
<head>
<link href="ctc.css" rel="stylesheet" type="text/css">
<php
echo Preface()
?>
<title>CodeThatTree lite sample</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#dbeaf5">

<php
echo ReadLevel(0)
?>

</body>
<html>

<php
/* Close the database connection */
mysql_close(); 
?>

 

[ Home ]  [ Contacts ]  [ Site Map ]  [ News ]  [ Links ]  [ Downloads ]

[ Go Top ]

© CodeThat.com, 2003-2010
Design by XTLabs, Inc
Sponsored by Rocket Division Software, LTD.