Current File : /home/inlingua/public_html/noida/icentex_noida/admin_cert/ingl_student.select.php
<?php
// Copyright, Panalink Infotech Limited. Created on: 27-11-2010

// Include header
include "header_cert.php";
?>
<h3>&nbsp;&nbsp;&nbsp;Students</h3>
<div id="contentnew">



<?php
echo "<br>";

function Certificate_d($student,$level)
{
if($level=="1A" || $level=="1B")
{
$cert="certificate_1_fd.php";
$tab="level_1";
}
elseif($level=="2A" || $level=="2B")
{
$cert="certificate_2_fd.php";
$tab="level_2";
}
elseif($level=="3A" || $level=="3B")
{
$cert="certificate_3_fd.php";
$tab="level_3";
}
elseif($level=="4")
{
$cert="certificate_4_fd.php";
$tab="level_4";
}
elseif($level=="5")
{
$cert="certificate_5_fd.php";
$tab="level_4";
}
else
{
$cert="#";
}

 $queryC="select count(recNo) as tot from ".$tab." where student_recNo='".$student."'";
$resultC=mysql_query($queryC);
$countT=@mysql_fetch_array($resultC);
if($countT[tot]>0)
{
$link="<a href='".$cert."?student=".$student."' target='_blank'><font size='1'>Download Certificate</font></a>";
}
else
{
//$link="<a href='".$cert."?student=".$student."' target='_blank'><font size='1'>Download Certificate</font></a>";
$link="<font size='1'>Not Generated Yet</font>";
}
return $link;

}


// Include the database connection details
require('../dbConnection.php');

// Include common functions
require('../commonFunc.php');

// Include common functions
require('../globalVars.php');

// Include the table handler class
require('../dbHandler.class.php');

// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();

?>
<?php if($_SESSION[msgE]!="") echo "<font color='red'> The Login Ids - ".$_SESSION[msgE]." are already exists.So cannot be added.</font>"; 
unset ($_SESSION[msgE]);
?>
<form action="ingl_student.select.php">
<b>Search</b>&nbsp;&nbsp; <?php 
$query="select * from ingl_course order by courseid";
$res=mysql_query($query);
if(mysql_num_rows($res)>0)
{
echo "<select name='courseId' onchange='displaystudent(this.value)'>";
echo"<option value=''>Select Course ID</option>";
while($rsult=mysql_fetch_array($res))
	{
	
	echo"<option value='".$rsult[recNo]."'" ;
	
	if($_REQUEST[courseId]==$rsult[recNo]) echo "selected";
	
	echo">".$rsult[courseid]."</option>";
	}
	echo"</select>";
}
else
{
echo "Please enter the Course ID ";
}
?>
&nbsp;&nbsp;and &nbsp;&nbsp;<b>Name</b>&nbsp;&nbsp;<input type="text" name="studentName" value="<?php echo $_REQUEST[studentName] ?>" />
<input type="hidden" name="search" value="1" />

<input class="submit1" type="Submit" value="Search" />
</form>
<br>
<?php


if($_REQUEST[courseId]!="" && $_REQUEST[studentName]=="")
{
$sqlQuery = "SELECT s.*, c.courseid as ccourseid  FROM ingl_student s left join ingl_course c on c.recNo = s.courseId
 where  s.courseId='".$_REQUEST[courseId]."' order by s.studentName Asc";
}
elseif($_REQUEST[courseId]=="" && $_REQUEST[studentName]!="")
{
$sqlQuery = "SELECT s.*, c.courseid as ccourseid  FROM ingl_student s left join ingl_course c on c.recNo = s.courseId where  s.studentName like '".$_REQUEST[studentName]."%' order by s.studentName Asc";
}
elseif($_REQUEST[courseId]!="" && $_REQUEST[studentName]!="")
{
$sqlQuery = "SELECT s.*, c.courseid as ccourseid FROM ingl_student s left join ingl_course c on c.recNo = s.courseId where   s.courseId='".$_REQUEST[courseId]."' && s.studentName like '".$_REQUEST[studentName]."%' order by s.studentName Asc";
}
else
{
// Records selection sql
 $sqlQuery = "SELECT s.*, c.courseid  as ccourseid FROM ingl_student s left join ingl_course c on c.recNo = s.courseId  order by s.studentName Asc";
}

// Prepare page navigation
$resultsPerPage = 20; // number of rows to return per page
$offset=$_REQUEST['offset'];
// Prepare add on URL
$addOnUrl = "&courseId=".$_REQUEST[courseId]."&studentName=".$_REQUEST[studentName];

if ($resultsPerPage > 0)
{	$prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
	$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}

// Print navigation bar
function printArray($element) { echo "$element"; }

if ($resultsPerPage > 0 && $prev_next_links)
{	//echo "Page: ";
	//array_walk($prev_next_links, 'printArray'); 
}

// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);

echo "<table border='1' class='pa-nor' cellspacing='0' width='100%'>";
echo "<tr valign='top' class='rowH'>";

echo "<th><b>Student Name</b></th>";
echo "<th><b>Course ID</b></th>";
echo "<th><b>Login</b></th>";
echo "<th><b>Password</b></th>";
echo "<th>Action</th>";
echo "</tr>";

// If no records selected, print message
if (!$selectedRecords)
{	echo "<tr><td colspan='5'>There are no selected records</td></tr>"; }
	
while($objectData=$dbObject->SelectNext())
{	
$level="select * from ingl_course where courseid='".$objectData[courseId]."'";
$resultL=mysql_query($level);
$numL=mysql_fetch_array($resultL);

echo "<tr valign='top' onmouseover=\"this.className='pa-row-highlight'\" onmouseout=\"this.className='pa-nor'\">";
	
echo "<td>$objectData[studentName]<br><a href='welcome_note.php?student=".$objectData['recNo']."' target='_blank'><font size='1'>Download Letter</font></a></td>";
echo "<td>$objectData[ccourseid]</td>";
echo "<td>$objectData[login]</td>";
echo "<td>$objectData[password]</td>";

	echo "<td><a href='ingl_student.main.php?aC=sM&kV=". $objectData['recNo'] ."&courseId=".$_REQUEST[courseId]."&studentName=".$_REQUEST[studentName]."'>Modify</a> |";
	echo "<a href='ingl_student.main.php?aC=sV&kV=". $objectData['recNo'] ."'>View</a> |";
	echo " <a href='ingl_student.main.php?aC=sD&kV=". $objectData['recNo'] ."&courseId=".$_REQUEST[courseId]."&studentName=".$_REQUEST[studentName]."'>Delete</a><br>".Certificate_d($objectData[recNo],$numL[level])." </td>";	
	echo "</tr>";
}
print "</table>";

// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
}
?>

</div>
<?php 
$dbObject->CloseConnection();

// Include footer
include "footer_cert.php";
?>