Location: PHPKode > scripts > Create Your Own Directory > cms/genscript.php
<?php
error_reporting(0);
require_once "auth/config.php";
$link = mysql_connect($hostname, $username,$password);
if($link)
{
	$dbcon = mysql_select_db($dbname,$link);
}

$open = fopen("../js/tree.js", "w");
$xxx = array();

function addid($whichid,$link)
{
	global $xxx;
	$qry="select name,id,des from type where parentid=$whichid";
	$res=mysql_query($qry,$link);
	while($row=mysql_fetch_array($res,MYSQL_ASSOC))
	{
		$name = $row['name'];
		//$name=strtolower($name);
		$id = $row['id'];

            $des = $row['des'];

		if($xxx[$whichid] != "")
		    $xxx[$whichid] = $xxx[$whichid]."#::$name::$id::$des::";
		else
		    $xxx[$whichid] = "::$name::$id::$des::";

		addid($id,$link,$xxx);
	}
	return;
}
addid(0,$link);

$str .= "var child = new Array();\n";
foreach($xxx as $key => $val)
{
	$str .= "child[$key] = \"".$val."\";\n";
}
fwrite($open, $str);

?>
Return current item: Create Your Own Directory