Location: PHPKode > projects > OpenCabling > opencabling/edit_field_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');

	$id_connection=$_REQUEST['id_conn'];
	$start_id=$_REQUEST['start_id'];
	$start_item=$_REQUEST['start_item'];
	$end_id=$_REQUEST['end_id'];
	$end_item=$_REQUEST['end_item'];
	$conn_type=$_REQUEST['conn_type'];
	$conn_name=$_REQUEST['conn_name'];
	$conn_description=$_REQUEST['conn_description'];
	$action=$_REQUEST['action'];

	echo "<script lang=javascript>";
	echo "var selconnection = top.left.document.getElementById('selconnection');";
	echo "selconnection.value=".$id_connection.";";
	echo "</script>";

        include "opendb.php";

	if ($action=="Update Connection") {
		$sql="update connections set connection_type=".$conn_type.", name='".$conn_name."', description='".$conn_description."', start_obj='".$start_id."', start_item='".$start_item."', end_obj='".$end_id."', end_item='".$end_item."' where id_connection='".$id_connection."'";
		$query=mysql_query($sql,$mysql_conn);

		print "<script lang='javascript'>";
		print "top.frames['bottom'].location.href='show_connection.php?object=".$start_id."&item=".$start_item."'";
		print "</script>";
	}

        $sql="select id_connection,start_obj,end_obj,start_item,end_item,start_connectors.connleft as sleft,start_connectors.connright as sright,end_connectors.connleft as eleft,end_connectors.connright as eright,cabletypes.html,conntypes.description as ctdescription, connections.name,connections.description,conntypes.id_conn_type
                        from connections,conntypes,connectors start_connectors, connectors end_connectors,cabletypes
                        where connections.id_connection=".$id_connection." and 
                                connections.connection_type=conntypes.id_conn_type and
                                conntypes.start_connector_type=start_connectors.id_connector_type and
                                conntypes.end_connector_type=end_connectors.id_connector_type and
                                conntypes.cable_type=cabletypes.id_cable_type";

	$query=mysql_query($sql,$mysql_conn);
	if (mysql_num_rows($query)>0) {
		
		$result=mysql_fetch_assoc($query);

                print "<div class=smalltext align=right>[Connection ID #".$result['id_connection']."]</div>";

	        print "<form name='choose' id='choose' action='edit_field_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'>";

        	$sql="select * from conntypes order by description";
        	$query=mysql_query($sql,$mysql_conn);
        	while ($subresult=mysql_fetch_assoc($query)) {
                	print "<option value='".$subresult['id_conn_type']."']";
			if ($subresult['id_conn_type']==$result['id_conn_type'])
				print " Selected ";
			print ">".$subresult['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>".$result['name']."</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>".$result['description']."</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=".$result['start_obj']." 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=".$result['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' value=".$result['end_obj']." 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 value=".$result['end_item']."></input></td>";
        	print "</tr>";
        	print "<tr><td></td><td><input type=submit name=action value='Update Connection'></input></td></tr>";
        	print "</table>";
		print "<input type=hidden name=id_conn value=".$id_connection."></input>";
		print "</form>";
                echo "<script lang=javascript>ShowObjectName(\"start_id\",\"start_name\");</script>";
                echo "<script lang=javascript>ShowObjectName(\"end_id\",\"end_name\");</script>";
		
	}
   	mysql_close($mysql_conn);
?>

<?php
        $mid->printFooter();
?>

</body>
</html>
Return current item: OpenCabling