Location: PHPKode > projects > OpenCabling > opencabling/show_objects.php
<?php
$parent=$_REQUEST['parent'];
$action=$_REQUEST['action'];

$jscript['expand']="collapse";
$jscript['collapse']="expand";

$image['expand']="minus.png";
$image['collapse']="plus.png";

include "opendb.php";

$sql="select * from objects where id_object='$parent' order by position";
$query=mysql_query($sql,$mysql_conn);
if (mysql_num_rows($query)>0) {
  $result=mysql_fetch_assoc($query);
  for ($i=0; $i<$result['level'];$i++) {
    print "<img src='images/blank.png' border=0>";
  }
  $type=$result['obj_type'];
  print "<a href='javascript:".$jscript[$action]."(".$result['id_object'].")'>";
  print "<img src='images/blank.png' border=0>";
  print "<img src='images/".$image[$action]."' border=0></img></a><a id='obj_".$result['id_object']."' href='javascript:select(".$result['id_object'].")'>".$result['name']."</a>";
}
if ($action=='expand') {
  $sql="select * from objtypes where id_obj_type='$type'";
  $query=mysql_query($sql,$mysql_conn);
  $result=mysql_fetch_assoc($query);
  $order=$result['pos_ordering'];
  
  $sql="select * from objects where parent_obj='$parent' order by position $order,name";
  $query=mysql_query($sql,$mysql_conn);
  while ($result=mysql_fetch_assoc($query)) {
    print "<div id='".$result['id_object']."' class='smalltext'>";
    print "<img src='images/blank.png' border=0>";
    for ($i=0; $i<$result['level'];$i++) {
      print "<img src='images/blank.png' border=0>";
    }
    print "<a href='javascript:expand(".$result['id_object'].")'><img src='images/plus.png' border=0></img><a id='obj_".$result['id_object']."' href='javascript:select(".$result['id_object'].")'>".$result['name']."</a>";
    print "</div>";
  }
}
mysql_close($mysql_conn);
?>
Return current item: OpenCabling