Location: PHPKode > projects > OpenCabling > opencabling/search_connection.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
<link rel="stylesheet" href="css/opencabling.css" type="text/css"></link>
<?php
require_once 'js/functions.js';
require_once 'phplayersmenu.inc.php';
$mid->printHeader();
?>
</head>
<body>
<?php

$mid->printMenu('hormenu1');

$conn_type=$_REQUEST['conn_type'];
$conn_name=$_REQUEST['conn_name'];
$conn_description=$_REQUEST['conn_description'];
$start_id=$_REQUEST['start_id'];
$end_id=$_REQUEST['end_id'];
$start_item=$_REQUEST['start_item'];
$end_item=$_REQUEST['end_item'];
$order=$_REQUEST['order'];

print "<B>Search Connection:</B>";

include "opendb.php";

if ($conn_type=="" && $conn_name=="" && $conn_description=="" && $start_id=="" && $end_id=="" && $start_item=="" && $end_item=="" && $order=="") {

  print "<form name='choose' id='choose' action='search_connection.php'>";
  print "<br>";
  print "<table border=0><tr><td align=right><span class=normaltext>Type of Connection:</span></td>";
  print "<td colspan=2><select name='conn_type'>";
  print "<option values='Choose'>Choose</option>";
  
  $sql="select * from conntypes order by description";
  $query=mysql_query($sql,$mysql_conn);
  while ($result=mysql_fetch_assoc($query)) {
    print "<option value='".$result['id_conn_type']."']>".$result['description']."</option>";
  }
  print "</select></td></tr>";
  print "<tr><td align=right><span class=normaltext>Name:</span></td>";
  print "<td><textarea name='conn_name' rows=2 cols=25></textarea></td>";
  print "</tr>";
  print "<tr><td align=right><span class=normaltext>Description:</span></td>";
  print "<td><textarea name='conn_description' rows=4 cols=25></textarea></td>";
  print "</tr>";
  print "<tr><td align=right><span class=normaltext>From object:</span></td>";
  print "<td><input type=text size=5 name=start_id id='start_id' value='".$start_object."' onchange='ShowObjectName(\"start_id\",\"start_name\")'></input>";
  print "<input type=text readonly name=start_name id='start_name'></input></td>";
  print "<td><button onClick='ChooseObject(\"start_id\",\"start_name\")' type='button'>Browse</button></td>";
  print "</tr>";
  print "<tr><td align=right><span class=normaltext>Item:</span></td>";
  print "<td><input type=text name=start_item value='".$start_item."'></input></td>";
  print "</tr>";
  print "<tr><td align=right><span class=normaltext>To object:</span></td>";
  print "<td><input type=text size=5 name=end_id id='end_id' onchange='ShowObjectName(\"end_id\",\"end_name\")'></input>";
  print "<input type=text readonly name=end_name id='end_name'></input></td>";
  print "<td><button onClick='ChooseObject(\"end_id\",\"end_name\")' type='button'>Browse</button></td>";
  print "</tr>";
  print "<tr><td align=right><span class=normaltext>Item:</span></td>";
  print "<td><input type=text name=end_item></input></td>";
  print "</tr>";
  print "<tr><td></td><td><input type=submit value='Search Connection'></input></td></tr>";
  print "</table>";
  
  mysql_close($mysql_conn);
  
} else {
  if ($conn_type=="Choose") $conn_type="";

  $select="select connections.start_item,connections.end_item,objstart.id_object sid_object,objstart.name sname,objtstart.brand sbrand,objtstart.category scategory,objtstart.type stype,objend.id_object eid_object,objend.name ename,objtend.brand ebrand,objtend.category ecategory,objtend.type etype,id_connection,connections.name name,connections.description description,conntypes.description ctdescription from connections,conntypes,objects objstart,objtypes objtstart,objects objend,objtypes objtend ";
  $filter="where objtstart.id_obj_type=objstart.obj_type and objtend.id_obj_type=objend.obj_type and connections.start_obj=objstart.id_object and connections.end_obj=objend.id_object and connections.connection_type=conntypes.id_conn_type";

  if ($conn_type<>"") $filter=$filter." and connection_type='".$conn_type."'";
  if ($conn_name<>"") $filter=$filter." and upper(connections.name) like upper('%".$conn_name."%')";
  if ($conn_description<>"") $filter=$filter." and upper(connections.description) like upper('%".$conn_description."%')";
  if ($start_id<>"") $filter=$filter." and ( connections.start_obj='".$start_id."' or connections.end_obj='".$start_id."')";
  if ($end_id<>"") $filter=$filter." and ( connections.start_obj='".$end_id."' or connections.end_obj='".$end_id."')";
  if ($start_item<>"") $filter=$filter." and ( connections.start_item='".$start_item."' or connections.end_item='".$start_item."')";
  if ($end_item<>"") $filter=$filter." and ( connections.start_item='".$end_item."' or connections.end_item='".$end_item."')";
  $sql=$select.$filter;

  if ($order!="") {
    $sql=$sql." order by ".$order;
  }
  
  $query=mysql_query($sql,$mysql_conn);

  $link="search_connection.php?conn_type=$conn_type&conn_name=".htmlentities($conn_name)."&conn_description=$conn_description&start_id=$start_id&end_id=$end_id&start_item=$start_item&end_item=$end_item";

  echo "<table><tr class=smalltext>";
  echo "<td><b><a href=\"".$link."&order=connections.id_connection\">ID</a></td>";
  echo "<td><b><a href=\"".$link."&order=connections.connection_type\">Type</a></td>";
  echo "<td><b><a href=\"".$link."&order=connections.name\">Name</a></td>";
  echo "<td><b><a href=\"".$link."&order=connections.start_obj\">From</a></td>";
  echo "<td><b><a href=\"".$link."&order=connections.start_item\">From port</a></td>";
  echo "<td><b><a href=\"".$link."&order=connections.end_obj\">To</a></td>";
  echo "<td><b><a href=\"".$link."&order=connections.end_item\">To port</a></td></tr>";

 while ($result=mysql_fetch_assoc($query)) {
   if ($bgcolor=='#aaaaaa')
     $bgcolor='#cccccc';
   else
     $bgcolor='#aaaaaa';
   echo "<tr bgcolor=$bgcolor class=smalltext>";
   echo "<td><a href=\"javascript:select_conn('".$result['start_item']."','c','".$result['sid_object']."')\">".$result['id_connection']."</a></td>";
   echo "<td><a href=\"javascript:select_conn('".$result['start_item']."','c','".$result['sid_object']."')\">".$result['ctdescription']."</a></td>";
   echo "<td><a href=\"javascript:select_conn('".$result['start_item']."','c','".$result['sid_object']."')\">".$result['name']." ".$result[description]."</a></td>";
   echo "<td><a href=\"javascript:select_obj(".$result['sid_object'].")\">#".$result['sid_object']." - ".$result['sname']." (<i>".$result['sbrand']." - ".$result['scategory']." - ".$result['stype'].")</i></a></td>";
   echo "<td><a href=\"javascript:select_conn('".$result['start_item']."','c','".$result['sid_object']."')\">".$result['start_item']."</a></td>";
   echo "<td><a href=\"javascript:select_obj(".$result['eid_object'].")\">#".$result['eid_object']." - ".$result['ename']." (<i>".$result['ebrand']." - ".$result['ecategory']." - ".$result['etype'].")</i></a></td>";
   echo "<td><a href=\"javascript:select_conn('".$result['start_item']."','c','".$result['sid_object']."')\">".$result['end_item']."</a></td>";
 echo "</tr>";
 }
 echo "</table>";

 // echo $sql;

}

?>

<?php
$mid->printFooter();
?>
     
</body>
</html>
Return current item: OpenCabling