this is for ADD_FORM-->
<form method="post" action="add_result.php" name="add">
<table width="548" border="0">
<tr>
<td width="155">Name: </td>
<td width="383">
<input type="text" name="name">
</td>
</tr>
<tr>
<td width="155">Nick Name: </td>
<td width="383">
<input type="text" name="nickname">
</td>
</tr>
<tr>
<td width="155">Department: </td>
<td width="383">
<input type="text" name="department">
</td>
</tr>
<tr>
<td width="155">Place:</td>
<td width="383">
<?
$con=odbc_connect("Webdb","","");
$sql="select * from lcoation";
$result=odbc_exec($con,$sql);
?>
<select name="location_id" size="1">
<option>---Select----</option>
<?
while(odbc_fetch_row($result))
{
echo "<option value=",odbc_result($result,"loc_id"),">",odbc_result($result,"location"),"</option>";
}
echo"</select>";
odbc_close($con);
?>
or
<input type="text" name="location_name">
</td>
</tr>
<tr>
<td width="155">Extension Number: </td>
<td width="383">
<input type="text" name="extension" size="10" >
</td>
</tr>
</table>
<hr>
This is for add_result form-->
$con=odbc_pconnect("Webdb","","");
if ($location_name == ""){
$sql="insert into data(nickname, name, acer_dept, tel_ext, loc_id) values ('$name', '$nickname', '$department', '$extension', '$location_id')";
$result=odbc_exec($con,$sql);
}
else
{
$addL=odbc_exec($con,"insert into location(location) values ('$location_name'))" );
$result=odbc_exec($con,"select loc_id from location where location= '$location_name'" );
$new_id=odbc_result($result,"loc_id");
$sql2="insert into data(nickname, name, acer_dept, tel_ext, loc_id) values ('$name', '$nickname', '$department', '$extension', '$new_id')";
$result2=odbc_do($con,$sql2);
}
echo "<br><br><br>";
echo"<p align='center'>NEW ENTRY ADDED!!</p>";
echo"<p></p>";
echo" Name: ".$name."<br>";
echo" Nick Name: ".$nickname."<br>";
echo" Department: ".$department."<br>";
echo" Extension Number: ".$extension."<br>";
if($location_id=="")
{
echo" Location: ".$location;
}
else
{
$addL=odbc_exec($con,"insert into location(location) values ('$location_name'))" );
$result=odbc_exec($con,"select loc_id from location where location= '$location_name'" );
echo" Location".$result;
}
?>
thanx alto!!!