<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();
?>
|