here are part of the code.hope can get a solution.thanks
<?php
session_start();
require_once("../db_function.php");
require_once("../auth.php");
require_once('../admin.php');
//logout();
if (isset($POST['Submit'])&&$POST['Submit']=="Add")
{
$flag=0;
$SupplyChainID=$POST['SupplyChainID'];
$Description=$POST['Description'];
$RCompanyID1=$POST['RCompanyID1'];
$CompanyName1=$POST['CompanyName'];
$RCompanyID2=$POST['RCompanyID2'];
$CompanyName=$POST['CompanyName'];
connect();
$query="select SupplyChainID, RCompanyID1,RCompanyID2 from relationships where SupplyChainID='$SupplyChainID'and
RCompanyID1='$RCompanyID1' and RCompanyID2='$RCompanyID2'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
if($num==0)
{
$flag=1;
?>
<script language="javascript">
alert("ERROR!Data not in database.")
</script>
<?php
}
else{
?>
<script language="javascript">
alert("The data already exist in database.")
</script>
<?php
$flag = 1;
}
if($flag == 0)
{
connect();
$query = "insert into relationships (SupplyChainID, RCompanyID1, RCompanyID2)
values ('$SupplyChainID','$RCompanyID1','$RCompanyID2')";
$result = mysql_query($query);
$ID = mysql_insert_id();
if(!$result)
$flag = 1;
}
}
$ID1 =$_POST['ID'];
$xMatchCompanyID = $_POST['xMatchCompanyID'];
$xMatchCompanyID1=$_POST['xMatchCompanyID'];
//$CompanyID = $_POST['CompanyID'];
connect();
$query1 = "select ID, Description from supply_chain order by Description";
$result1 = mysql_query($query1);
$num1 = mysql_num_rows($result1);
$queryUpperEntity = "select xMatchCompanyID, CompanyName from customers order by xMatchCompanyID";
$resultUpperEntity= mysql_query($queryUpperEntity);
$numUpperEntity= mysql_num_rows($resultUpperEntity);
$queryLowerEntity = "select xMatchCompanyID, CompanyName from customers order by xMatchCompanyID";
$resultLowerEntity = mysql_query($queryLowerEntity);
$numLowerEntity = mysql_num_rows($resultLowerEntity);
?>
<script language="JavaScript">
function change(objCombo)
{
document.form.ID1.value = document.form.Description.value;
}
function change1(objCombo)
{
document.form.xMatchCompanyID1.value = document.form.CompanyName1.value;
}
function change2(objCombo)
{
document.form.xMatchCompanyID.value = document.form.CompanyName.value;
}
</script>
</p>
<style type="text/css">
<!--
.style1 {font-size: x-large}
-->
</style>
<form name="form" method="post" action="add_supplychain_form.php">
<p align="center" class="style13 style1"><strong>Supply Chain Relationship </strong></p>
<p align="center" class="style13"> </p>
<p align="center" class="style13"> </p>
<table width="71%" border="2" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#CCFFFF">
<td width="45%" height="45" bordercolor="#FFFFFF" bgcolor="#FFFFCC"><span class="style12">Supply Chain : </span></td>
<td bgcolor="#FFFFCC"><select name="SupplyChainID" id="ID1" onChange="change(this);">
<?php
$flag = 0;
while($row = mysql_fetch_array($result1))
{
if($flag == 0)
{
$SupplyChainID = $row['ID'];
$flag = 1;
}
if($row['Description'] == $Description)
echo "<option value='".$row['Description']."' selected>".$row['ID']."</option>";
else
echo "<option value='".$row['Description']."'>".$row['ID']."</option>";
}
?>
</select></td>
<tr bgcolor="#CCFFFF">
<td width="45%" height="45" bordercolor="#FFFFFF"><span class="style12">Chain Description : </span></td>
<td width="55%" bgcolor="#CCFFFF"><input name="Description" type="text" id="Description" value="<?php echo $Description; ?>"></td>
</tr>