I want to create dhtml file based on the database. Here is sample

Menu Table
============
Fields are menu_id,menu_name,menu_parent
Records
1,Home,0
2,Product,0
3,Computer,2
4,Mobile,2
5,Nokia,4
6,Ericson,4
7,Nokia 8250,5
8,Nokia 6600,5
8,T630,6
9,P900,6

Home Product
     -Computer
     -Mobile
     	-Nokia
     		-Nokia 8250
     		-Nokia 6600

 	-Ericson
 		-T630
 		-P900






//DHTML structure
//Top Level menu where parent=0)
//Its code is differn then any other menu
//Menu name should be always MainMenu where menu_parent=0
with(new fxmenu("MainMenu")){
	style=itemStyle;
	menustyle=menuStyle;
	visible=true;
	position="absolute";
	top=30;
	left=59;
	orientation="horizontal";
	fx("text=Home;url=index.html;width=66;title=Home;");
	fx("text=Product;show=Product;width=79;title=The Menu - reloaded;");
}
//Child menu (Product got children so, we create new 
//menu with different code
//Remember Home does not have any child so we dont
//do anything

with(new fxmenu("Product")){
	style=itemStyle;
	menustyle=menuStyle;
	width=190;
	fx("text=Computer;url=computer.html;");//Notice i used url,because computer has no childs
	fx("text=Mobile;show=Mobile;");//notice i use "show" because Mobile has children
}

// As child menu Mobile has childs
with(new fxmenu("Mobile")){
	style=itemStyle;
	menustyle=menuStyle;
	width=190;
	fx("text=Nokia;show=Nokia;");
	fx("text=Ericson;show=Ericson;");
}


with(new fxmenu("Nokia")){
	style=itemStyle;
	menustyle=menuStyle;
	width=190;
	fx("text=Nokia 8250;url=8260.html;");
	fx("text=Nokia 6600;url=6600.html;");
}


with(new fxmenu("Ericson")){
	style=itemStyle;
	menustyle=menuStyle;
	width=190;
	fx("text=T630;show=t630.html;");
	fx("text=P900;url=p900.html;");
}

And my attempt code. It display top
level where parent=0

with(new fxmenu("MainMenu")){
style=itemStyle;
menustyle=menuStyle;
visible=true;
position="relative";
top=30;
left=59;
orientation="horizontal";
<?php
global $db,$prefix;
$result=$db->query("SELECT menu_id,menu_name FROM ".$prefix."_,menu WHERE menu_parent=0");
	while($row=$db->fetch_array($result)){
	if(haschild($row[menu_id])){
		$m=" url:someurl";
	}else{
		$m="show:$row[menu_name]";
	}
	echo"fx('text=$row[menu_name];url=index.php?load=iframe&cid=$row[menu_id];title=$row[content_name];$m');";
}


function haschild($id){
	global $db;
	$result=$db->query("SELECT menu_id  FROM ".$prefix."_menu WHERE menu_parent=$id");
	return ($db->row_count($result) > 0);
}

?>

}

<?php
function mymenu($parentid,$title,$x="") {
	global $prefix,$db;
	$result=$db->query("select menu_id, menu_name,menu_parent,menu_width from ".$prefix."_menu where menu_parent=$parentid");
	while($row=$db->fetch_array($result)){
		echo"with(new fxmenu('$title')){\n";
		echo"style=itemStyle;\n";
		echo"menustyle=menuStyle;\n";
		echo"width=$row[menu_width];\n";
		while(list($cid, $ptitle, $pparentid) =$db->fetch_row($result)){
			if(haschild($cid)){
				echo"fx('text=$ptitle;show=$ptitle')\n";

		}else{
			echo"fx('text=$ptitle;url=index.php?load=iframe&cid=$cid;')\n";
		}
	}
	echo"}\n";

}

}
?>

    But ... you haven't actually told us what your problem is! Might also be better in future just to include small relevant clips of code where possible rather than the full script.

      I have posted above sample to show what I want.

      Here is my code. The problem is Its going upto one level.

      function mymenu($parentid,$title,$width) {
      	global $prefix,$db;
      	$result=$db->query("select content_id, content_name,content_parent,content_width from ".$prefix."_content where content_parent=$parentid");
      	$found=$db->row_count($result);
      	if($found>0){
      
      echo"with(new fxmenu('$title')){\n";
      		echo"style=itemStyle;\n";
      		echo"menustyle=menuStyle;\n";
      		echo"width=$width;\n";
      while($row=$db->fetch_array($result)){
      		if(haschild($row[content_id])){
      			echo"fx('text=$row[content_name];show=$row[content_name]')\n";
      		}else{
      			echo"fx('text=$row[content_name];url=index.php?load=iframe&cid=$row[content_id];')\n";
      		}
      
      
      }
      		echo"}\n";
      }
      }
      
        Write a Reply...