In the following code the section semester only show the semester value but related combo box for subject not working please guide the code in pink color not working
<?php
session_start();
if (!array_key_exists("user", $_SESSION)) {
header('Location: index.php');
exit;
}
function valid($instid,$title,$f_name,$e_mail,$mobile_numb,$designation,$sem, $area_exp,$year_exp,$course_id, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta charset="utf-8">
<title>SimpleAdmin - Full width page</title>
<!-- Stylesheets -->
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet'>
<link rel="stylesheet" href="css/design.css">
<!-- Optimize for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- jQuery & JS files -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/script.js"></script>
<script language="javascript" type="text/javascript">
function showCompany(catid) {
document.create.submit();
}
</script>
</head>
<body>
<?php
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<div class="box">
<form action="" method="post" name="create" id="create">
<fieldset>
<table>
<thead><tr>
<th><b>Insert Records</b></th>
</tr>
<tr>
<th><b><font color='white'>Institute ID<em>*</em></font></b></th>
<th><b><font color='white'>Title<em>*</em></font></b></th>
<th><b><font color='white'>Examiner Name<em>*</em></font></b></th>
<th><b><font color='white'>Examiner Email Address<em>*</em></font></b></th>
<th><b><font color='white'>Examiner Mobile Number<em>*</em></font></b></th>
<th><b><font color='white'>Designation<em>*</em></font></b></th>
<th><b><font color='white'>Semester<em>*</em></font></b></th>
<th><b><font color='white'>Subject<em>*</em></font></b></th>
<th><b><font color='white'>Experience in Year<em>*</em></font></b></th>
<th><b><font color='white'>Course<em>*</em></font></b></th>
</tr>
</thead>
<tbody>
<tr>
<td><label>
<input type="text" readonly="readonly" name="instid" id="instid"
value="<?php
require_once("Includes/db.php");
$userID = userDB::getInstance()->get_hod_id_by_name($_SESSION['user']);
$result = userDB::getInstance()->get_institute_by_user_id($userID);
while($instid = mysqli_fetch_array($result)):echo ($instid['instid']);?> <?php
endwhile;
mysqli_free_result($result);
?> " />
</label></td>
<td><label>
<input type="text" name="title" id="title" value="<?php echo $title; ?>" />
</label></td>
<td><label>
<input type="text" name="f_name" id="f_name" value="<?php echo $f_name; ?>" />
</label></td>
<td><label>
<input type="text" name="e_mail" id="e_mail" value="<?php echo $e_mail; ?>" />
</label></td>
<td><label>
<input type="text" name="mobile_numb" id="mobile_numb" value="<?php echo $mobile_numb; ?>" />
</label></td>
<td><label>
<input type="text" name="designation" id="designation" value="<?php echo $designation; ?>" />
</label></td>
<td width="371">
<select name="sem" id="sem" onChange="showCompany(this.value);">
<option value="">--Select--</option>
<?php
include('config.php');
$sql1="select * from semester";
$sql_row1=mysql_query($sql1);
while($sql_res1=mysql_fetch_assoc($sql_row1))
{
?>
<option value="<?php echo $sql_res1["id"]; ?>" <?php $sem1 = isset($_REQUEST["sem1"]) ? $_REQUEST["sem1"] : '';if($sql_res1["id"]==$sem1) { echo "Selected"; } ?>><?php echo $sql_res1["sem"]; ?></option>
<?php
}
?>
</select>
</td>
<td id="td_subject">
<select name="area_exp" id="area_exp">
<option value="">--Select--</option>
<?php
include('config.php');
$sql="select * from subject where sem_id='$sem1' and course='Computer Engineering'";
$sql_row=mysql_query($sql);
while($sql_res=mysql_fetch_assoc($sql_row))
{
?>
<option value="<?php echo $sql_res["id"]; ?>"><?php echo $sql_res["sub_name"]; ?></option>
<?php
}
?>
</select>
</td>
<td><label>
<input type="text" name="year_exp" id="year_exp" value="<?php echo $year_exp; ?>" />
</label></td>
<td><label>
<input type="text" readonly="readonly" name="course_id" value="Computer Engineering" />
</label></td>
</tr>
<tr align="Right">
<td colspan="2"><label>
<input type="submit" name="submit" onClick="check()" value="Insert Records">
</label></td>
</tr>
</tbody>
</table>
</fieldset>
</form>
</div>
<table>
<thead>
<th>Institute Code</th>
<th>Title</th>
<th>Examiner<br> Name</th>
<th>Email<br>Address</th>
<th>Mobile<br> Number</th>
<th>Designation</th>
<th>Area of<br> Expertise</th>
<th>Year of<br> Experience</th>
<th>Course</th>
<th>Edit</th>
<th>Delete</th>
</thead>
<tbody>
<?php
include('config.php');
$result1 = mysql_query("SELECT * FROM examinerinfo WHERE course_id='Computer Engineering' ORDER BY id DESC")
or die(mysql_error());
while($row = mysql_fetch_array( $result1 ))
{
?>
<tr>
<td> <?php echo($row['instid'])?> </td>
<td> <?php echo($row['title'])?> </td>
<td> <?php echo($row['f_name'])?> </td>
<td> <?php echo($row['e_mail'])?></td>
<td> <?php echo ($row['mobile_numb'])?></td>
<td> <?php echo($row['designation'])?> </td>
<td> <?php echo($row['sem'])?> </td>
<td> <?php echo($row['area_exp'])?> </td>
<td> <?php echo($row['year_exp'])?> </td>
<td> <?php echo($row['course_id'] )?></td>
<td>
<a href="#" class="table-actions-button ic-table-edit"></a></td>
<td><a href="#" onclick="return confirm('Are you sure want to delete?');" class="table-actions-button ic-table-delete"></a>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="5" class="table-footer">
<label for="table-select-actions">With selected:</label>
<select id="table-select-actions">
<option value="option1">Delete</option>
<option value="option2">Export</option>
<option value="option3">Archive</option>
</select>
<a href="#" class="round button blue text-upper small-button">Apply to selected</a>
</td>
</tr>
</tfoot>
</table>
</div> <!-- end content-module-main -->
</div> <!-- end content-module -->
</div> <!-- end full-width -->
</div> <!-- end content -->
<script language="JavaScript">
function check1()
{
document.create.submit()
}
function check()
{
if(document.create.instid.value=="")
{
alert("Please enter Institute ID")
document.create.instid.focus()
}
else if(document.create.title.value=="")
{
alert("Please enter Title")
document.create.title.focus()
}
else if(document.create.f_name.value=="")
{
alert("Please enter full name")
document.create.f_name.focus()
}
else if(document.create.e_mail.value=="")
{
alert("please enter e-mail address")
document.create.e_mail.focus()
}
else if(document.create.mobile_numb.value=="")
{
alert("Please enter Mobile Number")
document.create.mobile_numb.focus()
}
else if(document.create.designation.value=="")
{
alert("Please enter Examiner Designation")
document.create.designation.focus()
}
else if(document.create.sem.value=="")
{
alert("Please enter Semester")
document.create.sem.focus()
}
else if(document.create.area_exp.value=="")
{
alert("Please enter Examiner Area of Experience")
document.create.area_exp.focus()
}
else if(document.create.year_exp.value=="")
{
alert("Please enter Examiner Teaching Experience")
document.create.year_exp.focus()
}
else if(document.create.course_id.value=="")
{
alert("Please enter full name")
document.create.course_id.focus()
}
else
{
getlength()
}
}
function getlength()
{
var val=document.create.eMail.value;
var loc=val.indexOf("@");
if(loc=="-1")
{
alert("Invalid Email address");
}
else
pos()
}
function pos()
{
var val=document.create.eMail.value;
var loc=val.indexOf("@");
if(loc==0)
{
alert("Invalid Email address");
return true;
}
else
dot()
}
function dot()
{
var val=document.create.eMail.value;
var locdot=val.indexOf(".");
var loc=val.indexOf("@");
var sub;
if(locdot=="-1")
{
alert("Invalid Email address");
}
else
posdot()
}
function posdot()
{
var val=document.create.eMail.value;
var locdot=val.indexOf(".");
if(locdot==0)
{
alert("Invalid Email address");
return true;
}
else
check1()
}
</script>
</body>
</html>
<?php
}
include('config.php');
if (isset($_POST['submit']))
{
$instid = mysql_real_escape_string(htmlspecialchars($_POST['instid']));
$title = mysql_real_escape_string(htmlspecialchars($_POST['title']));
$f_name = mysql_real_escape_string(htmlspecialchars($_POST['f_name']));
$e_mail = mysql_real_escape_string(htmlspecialchars($_POST['e_mail']));
$mobile_numb = mysql_real_escape_string(htmlspecialchars($_POST['mobile_numb']));
$designation = mysql_real_escape_string(htmlspecialchars($_POST['designation']));
$sem = mysql_real_escape_string(htmlspecialchars($_POST['sem']));
$area_exp = mysql_real_escape_string(htmlspecialchars($_POST['area_exp']));
$year_exp = mysql_real_escape_string(htmlspecialchars($_POST['year_exp']));
$course_id = mysql_real_escape_string(htmlspecialchars($_POST['course_id']));
if ($instid == '' || $title == '' || $f_name == '' ||
$e_mail == '' || $mobile_numb == ''|| $designation == '' ||
$sem== '' || $area_exp == '' || $year_exp == ''|| $course_id == '')
{
$error = 'Please enter the details!';
valid($instid,$title,$f_name,$e_mail,$mobile_numb,$designation,$sem, $area_exp, $year_exp,$course_id,$error);
}
else
{
mysql_query("INSERT examinerinfo SET instid='$instid',title='$title', f_name='$f_name',
e_mail='$e_mail',mobile_numb='$mobile_numb',designation='$designation',
sem='$sem',area_exp='$area_exp', year_exp='$year_exp', course_id='$course_id'")
or die(mysql_error());
header("Location: co.php");
}
}
else
{
valid('','','','','','','','','','','');
}
?>
v