<?php include("includes/config.php"); 
if(isset($_POST['submit'])){
	$roll = $_POST['roll'];
	$class = $_POST['class_roll'];
	$sql=mysql_query("select * from `result` where `roll_no`='$roll' AND `class`='$class'");
	$rs=mysql_fetch_array($sql);
	$done = 1;	
}
if(isset($_POST['zubmit'])){
	$name = $_POST['name'];
	$class = $_POST['class_name'];
	$sql=mysql_query("select * from `result` where `name` like '$name' AND `class`='$class'");
	$rs=mysql_fetch_array($sql);
	$done = 2;	
}
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Online Result : Frontier Public High School</title>
<link rel="stylesheet" type="text/css" href="styles/my.css"  />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
 <script src='js/jquery-1.7.2.min.js' type='text/javascript'></script>
<script src='js/sfm_validatorv7.js' type='text/javascript'></script>
</head>

<body>
<!-- Wrapper Starts Here -->
<div id="wrapper">
<?php 
include("includes/header.php");
//include("includes/slideshow.php");
?>
<!-- Contents Starts -->
<div class="content">
<h3 style="font-size:20px;"> Frontier Public High School Result </h3>
<?php if(isset($done) && $done == 1){
		if($roll==$rs['roll_no'] && $class == $rs['class']){ ?>
	<div style="margin:5px; margin-left:10px; padding:5px;">
  <table width="80%" border="0" cellspacing="1" style="color:white;">
    <tr>
      <th align="center" bgcolor="#006699" scope="col">Name</th>
      <th align="center" bgcolor="#006699" scope="col">Roll No</th>
      <th align="center" bgcolor="#006699" scope="col">Class</th>
      <th align="center" bgcolor="#006699" scope="col">Obtained Marks</th>
      <th align="center" bgcolor="#006699" scope="col">Total Marks</th>
    </tr>
    <tr style="color:black;">
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['name']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['roll_no']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['class']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['obtained_marks']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['total_marks']; ?>&nbsp;</th>
    </tr>
  </table>
</div> 

<?php }
else if(isset($_POST['submit'])) { ?>
<div style="border:1px solid #FF0000; border-radius:6px; background:#FC0; width:460px; margin:10px;">
<p style="padding-left:36px;"> <strong>No Record Found!</strong> Please Enter correct Roll # & Class! </p></div><br /><?php } } ?>
<?php if(isset($done) && $done == 2){
		if($name==$rs['name'] && $class == $rs['class']){ ?>
	<div style="margin:5px; padding:5px; margin-left:10px;">
  <table width="80%" border="0" cellspacing="1" style="color:white;">
    <tr>
      <th align="center" bgcolor="#006699" scope="col">Name</th>
      <th align="center" bgcolor="#006699" scope="col">Roll No</th>
      <th align="center" bgcolor="#006699" scope="col">Class</th>
      <th align="center" bgcolor="#006699" scope="col">Obtained Marks</th>
      <th align="center" bgcolor="#006699" scope="col">Total Marks</th>
    </tr>
    <tr style="color:black;">
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['name']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['roll_no']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['class']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['obtained_marks']; ?>&nbsp;</th>
      <th align="center" bgcolor="#6699CC" scope="col"><?php echo $rs['total_marks']; ?>&nbsp;</th>
    </tr>
  </table>
</div> 

<?php }
else if(isset($_POST['zubmit'])) { ?>
<div style="border:1px solid #FF0000; border-radius:6px; background:#FC0; width:460px; margin:10px;">
<p style="padding-left:36px;"> <strong>No Record Found!</strong> Please Enter correct Name & Class! </p></div><br /><?php } } ?>

<div style="float:left">
<form action="result.php?action=searchbyroll" method="post" enctype="multipart/form-data" name="searchbyroll" id="searchbyroll">
 <fieldset style="width:250px; margin-left:20px;">
 <legend> Search by Roll No </legend> <table width="250" border="0" align="left">
    <tr>
      <td scope="col">&nbsp;</td>
      <td width="26%" scope="col">Roll #</td>
      <td width="66%" scope="col"><input type="text" name="roll" id="roll" required /></td>
    </tr>
    <tr>
      <td scope="col">&nbsp;</td>
      <td scope="col">class </td>
      <td scope="col"><select name="class_roll" class="size3" id="class_roll">
        <option value="Select Class">Select Class</option>
        <option value="Play Group">Play Group</option>
        <option value="Nursery">Nursery</option>
        <option value="Prep">Prep</option>
        <option value="1st">1st</option>
        <option value="2nd">2nd</option>
        <option value="3rd">3rd</option>
        <option value="4th ">4th</option>
        <option value="5th ">5th </option>
        <option value="6th">6th </option>
        <option value="7th">7th</option>
        <option value="8th">8th</option>
        <option value="9th">9th</option>
        <option value="10th">10th</option>
      </select></td>
    </tr>
    <tr>
      <td scope="col">&nbsp;</td>
      <td scope="col">&nbsp;</td>
      <td scope="col"><input type="submit" name="submit" id="button" value="Submit" /></td>
    </tr>
  </table>
  </fieldset>
</form>
<script type='text/javascript'>
// <![CDATA[
var searchbyrollValidator = new Validator("searchbyroll",{enable_smart_live_validation:false, message_style:'messagebox'});
searchbyrollValidator.addValidation("roll",{numeric:true,message:"The input for Roll No should be a valid numeric value"} );
// ]]>
</script>
</div>
<div style="float:left; padding-left:16px;">
<form action="result.php?action=searchbyname" method="post" enctype="multipart/form-data" name="searchbyname" id="searchbyname">
  <fieldset style="width:250px;">
  <legend>Search by Name </legend>
  <table width="250" border="0" align="left">
    <tr>
      <td scope="col">&nbsp;</td>
      <td width="26%" scope="col">Name</td>
      <td width="66%" scope="col"><input type="text" name="name" id="name" required /></td>
    </tr>
    <tr>
      <td scope="col">&nbsp;</td>
      <td scope="col">class </td>
      <td scope="col"><select name="class_name" class="size3" id="class_name">
        <option value="Select Class">Select Class</option>
        <option value="Play Group">Play Group</option>
        <option value="Nursery">Nursery</option>
        <option value="Prep">Prep</option>
        <option value="1st">1st</option>
        <option value="2nd">2nd</option>
        <option value="3rd">3rd</option>
        <option value="4th ">4th</option>
        <option value="5th ">5th </option>
        <option value="6th">6th </option>
        <option value="7th">7th</option>
        <option value="8th">8th</option>
        <option value="9th">9th</option>
        <option value="10th">10th</option>
      </select></td>
    </tr>
    <tr>
      <td scope="col">&nbsp;</td>
      <td scope="col">&nbsp;</td>
      <td scope="col"><input type="submit" name="zubmit" id="button" value="Submit" /></td>
    </tr>
  </table>
  </fieldset>
</form>
<script type='text/javascript'>
// <![CDATA[
var searchbynameValidator = new Validator("searchbyname",{enable_smart_live_validation:false, message_style:'messagebox'});
searchbynameValidator.addValidation("name",{alpha_s:true,message:"Invalid Name, Please Enter Correct Name"} );
// ]]>
</script>

</div>
</div>
<!-- Contents Ends -->
<?php
include("includes/sidebar.php");
include("includes/footer.php");
?>
</div>
<!-- Wrapper Ends -->
</body>
</html>
