<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<script language="javascript">
<!--
var t,lit,i;
function tree(liter) {
lit=liter;//
i=1;//
t = setInterval(show, 2); ///
//t = show();
}
function show() {
var el;
if(el = document.getElementById(lit + "." + i)) {
el.style.display = (el.style.display == 'block')?'none':'block';
i++;
}
else clearInterval(t);
}
-->
</script>
</head>
<body>
<?php
$host = "localhost";
$namedb = "vmode_ps";
$user_login = "vmode_ps";
$user_password = "1q2w3e4r5t";
$db = mysql_connect($host, $user_login, $user_password) or die(mysql_error());
mysql_select_db($namedb, $db) or die(mysql_error());
@mysql_query ("SET NAMES `cp1251`");
$sql_pid = "SELECT DISTINCT pid FROM tb_servers";
$result_sql_pid = mysql_query($sql_pid, $db);
$pid_arr = array();
while ($row_result_sql_pid = mysql_fetch_array($result_sql_pid))
{
$pid_arr[] = $row_result_sql_pid['pid'];
}
function ShowTree($ParentID, $lvl) {
global $name_res;
global $ip_res;
global $db;
global $lvl;
global $pid_arr;
$lvl++;
$sSQL="SELECT id,name,pid,ip FROM tb_servers WHERE pid=".$ParentID."";
$result=mysql_query($sSQL, $db);
if (mysql_num_rows($result) > 0) {
echo("<ul>\n");
while ( $row = mysql_fetch_array($result) ) {
$ID1 = $row["id"];
$i++;
if (in_array($ID1, $pid_arr)){
$pref = "-PARENT";
$style1 = "onclick=\"tree('".$ID1."')\"";
}
if (!in_array($ID1, $pid_arr) || $lvl >= 2){
$style2 = "id='".$row['pid'].".".$i."' style='display: none';";
}
echo("<li ".$style2.">\n");
echo 'Жопа';
echo("<a ".$style1." title='".$row["name"]."'>".$row["name"]./*$pref."-LVL-".$lvl.*/"</a>"." \n");
ShowTree($ID1, $lvl);
$lvl--;
}
echo("</ul>\n");
}
}
ShowTree(0, 0);
?>
</body>
</html>