[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 header("Content-type:text/xml"); 3 require_once ('config.php'); 4 print("<?xml version=\"1.0\"?>"); 5 ?> 6 <tree id="0"> 7 <?php 8 $link = mysql_pconnect($mysql_host, $mysql_user, $mysql_pasw); 9 $db = mysql_select_db ($mysql_db); 10 //Create database and table if doesn't exists 11 if(!$db){ 12 //mysql_create_db($mysql_db,$link); 13 $sql = "Create database ".$mysql_db; 14 $res = mysql_query ($sql); 15 $sql = "use ".$mysql_db; 16 $res = mysql_query ($sql); 17 $sql = "CREATE TABLE Tree (item_id INT UNSIGNED not null AUTO_INCREMENT,item_nm VARCHAR (200) DEFAULT '0',item_order INT UNSIGNED DEFAULT '0',item_desc TEXT ,item_parent_id INT UNSIGNED DEFAULT '0',PRIMARY KEY ( item_id ))"; 18 $res = mysql_query ($sql); 19 if(!$res){ 20 echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>"; 21 } 22 } 23 getLevelFromDB(0); 24 mysql_close($link); 25 26 //print one level of the tree, based on parent_id 27 function getLevelFromDB($parent_id){ 28 $sql = "Select item_id, item_nm from Tree where item_parent_id=$parent_id"; 29 $res = mysql_query ($sql); 30 if($res){ 31 while($row=mysql_fetch_array($res)){ 32 print("<item id='".$row['item_id']."' text=\"". str_replace('"',""",$row['item_nm'])."\">"); 33 getLevelFromDB($row['item_id']); 34 print("</item>"); 35 } 36 }else{ 37 echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>"; 38 } 39 } 40 ?> 41 </tree>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |