<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<html>
<body>


<?
session_start();
include("opendb.php");
?>
<CENTER>
<?
if($upd)
{
 mysqli_query($db,"update pcmaster set plat='$plat',criteria='$criteria',val='$val' where sno='$cde' and brcode='$brcode'") or die(mysqli_error());
}
if($edit)
{
 $re=mysqli_query($db,"select * from pcmaster where sno='$cde'");
 $ro=mysqli_fetch_array($re);
?>
<form action='<?print $PHP_SELF?>' method='post'>
 <input type=hidden name=cde value='<?Print $cde?>'>
  <table border="0" cellpadding="4" cellspacing="1" bgcolor='#B0C4DE'>
    <tr>
      <td colspan="9" align="center"  height="17" bgcolor="steelblue">
<font color=white><B>EDIT PLATFORM  / CRITERIAL MASTER</td>
    </tr>
<TR><TD><select name='plat'>
 	<option><?print $ro[plat]?></option>
	<option>S0</option>
	<option>S1</option>
	<option>S2</option>
	<option>S3</option>
	<option>S4</option>
	<option>S5</option>
	</select>
	</td>
	<td><input type=text name='criteria' size=40 maxlength=50 value='<?print $ro[criteria]?>'></td>
	<td>Value</td><td><input type=text name='val' size=3 value='<?print $ro[val]?>'></td></tr>
</tr>
<tr><td colspan=2 align=center><input type=submit value='Update ' name='upd'></td></tr>
</table>
</form>


<?
return;
}

if($add)
{
 $re=mysqli_query($db,"select * from pcmaster where criteria='$criteria'");
 if(mysqli_num_rows($re)>0)
 { 
   print "<script> alert('Criteria already exists'); history.go(-1) </script>";
   return;
 }
 $sql="insert into pcmaster(plat,criteria,val,brcode) values('$plat','$criteria','$val','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error());
 $plat='';
}
?>
<form action='pcmaster.php' method='post'>
  <table border="0" cellpadding="4" cellspacing="1" bgcolor='#B0C4DE'>
    <tr>
      <td colspan="9" align="center"  height="17" bgcolor="steelblue">
<font color=white><B>PLATFORM  / CRITERIAL MASTER</td>
    </tr>
<TR><TD><select name='plat'>
	<option>S0</option>
	<option>S1</option>
	<option>S2</option>
	<option>S3</option>
	<option>S4</option>
	<option>S5</option>
	</select>
	</td>
	<td><input type=text name='criteria' size=40 maxlength=50></td>
	<td>Value</td><td><input type=text name='val' size=5></td></tr>
</tr>
<tr><td colspan=2 align=center><input type=submit value='Add' name='add'></td></tr>
</table>
</form>

  <table border="0" cellpadding="4" cellspacing="1" bgcolor='#B0C4DE'>
    <th>Platform <th>Criteria <th>Value <th>Action
<?
$re=mysqli_query($db,"select * from pcmaster order by val");
while($row=mysqli_fetch_row($re))
{
 print "\n<form action='$PHP_SELF'><input type=hidden name='cde' value='$row[0]'>";
 print "<tr bgcolor=white><td>$row[1]</td>";
 print "<td>$row[2]</td><td><center>$row[3]</td><td align=center><input type=submit value='Edit' name='edit'>";
 print "</tr></form>";
}
?>
</table>


