<?php
include("config.php");
extract($_POST);
extract($_GET); 

echo"<html dir=\"rtl\">";
echo"<head>";
echo"<meta http-equiv=\"Content-Language\" content=\"en-us\">";
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1256\">";
echo"<title> </title>";
echo"</head>";
echo"<body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" bgcolor=\"#B7E1F9\">";
echo"<div align=\"center\">";
//  
echo"<form action=\"add_sub.php?do=add\" method=\"post\" />";
echo"	<table border=\"0\" width=\"450\" dir=\"rtl\" cellspacing=\"0\" cellpadding=\"0\">";
echo"		<tr>";
echo"			<td valign=\"top\" width=\"307\">";
echo"			";
echo"			<p align=\"right\"><font size=\"4\" color=\"#000080\">   ";
echo"			:</font></td>";
echo"			<td width=\"288\">";
echo"			";
//    
// parts    
echo"			<select size=\"1\" name=\"par_name\" dir=\"rtl\">";

 $e= mysql_query("select * from parts");
        while($row=mysql_fetch_array($e)){
        extract($row);
echo"			<option value=\"$par_id\">$par_name</option>";
}
echo"			</select></td>";

echo"		</tr>";
echo"		<tr>";
echo"			<td valign=\"top\" width=\"307\">";
echo"			<p align=\"right\"><font size=\"4\" color=\"#000080\">   ";
echo"			:</font></td>";
echo"			<td width=\"288\">";
//    
// class    

echo"<p align=\"right\"><select size=\"1\" name=\"class_name\" dir=\"rtl\">";
$e= mysql_query("select * from class order by class_no");
        while($row=mysql_fetch_array($e)){
        extract($row);
echo"			<option value=\"$class_id\">$class_name</option>";
}
echo"			</select></td>";

echo"		</tr>";
echo"		<tr>";
echo"			<td valign=\"top\" width=\"307\">";

echo"			<p align=\"right\"><font size=\"4\" color=\"#000080\">   ";
echo"			  :</font></td>";
echo"			<td width=\"288\">";
echo"			";
echo"			<p align=\"right\"><input type=\"text\" name=\"sub_name\" size=\"20\"></td>";
echo"		</tr>";
echo"		<tr>";
echo"			<td colspan=\"2\">";

echo"			<p align=\"center\"><input type=\"submit\" value=\"\" name=\"B1\"><input type=\"reset\" value=\"\" name=\"B2\"></td>";
echo"		</tr>";
echo"		<tr>";
echo"			<td colspan=\"2\">";
echo"			</td>";
echo"		</tr>";
echo"		</form>";
//  
echo"	</table>";
echo"</div>";
echo"</body>";
echo"</html>";

//    
 if($do=="add"){
                    $addcat=mysql_query("insert into subjects (sub_name,par_id,class_id)values('$sub_name','$par_name','$class_name') ");
                    if($addcat){ 
										echo'    ';  
									echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=fadd_sub.php'>"; 
										} 
                    else { 
										echo'     '; 
										
										}							
                  }
                  
//   
echo"<p align=center>";
echo " ";
echo "<br>";  
echo "=====================================================";      