Filename : search_student.php
Expand|Select|Wrap|Line Numbers
- <?php
- include("../user_access/user_access_control.php");
- include("../Database/database.php");
- $searchStudentControl = new Access_user;
- // call the levelAccess method to check the user access level
- $searchStudentControl->levelAccess($_SESSION['level'],1);
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Untitled Document</title>
- <style type="text/css">
- <!--
- body {
- margin-left: 0px;
- margin-top: 0px;
- margin-right: 0px;
- margin-bottom: 0px;
- }
- .style1 {
- font-size: 18px;
- color: #FFFFFF;
- }
- -->
- </style>
- <script type="text/javascript" src="engine.js"></script>
- </head>
- <body>
- <table width="707" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="62" height="31"> </td>
- <td colspan="5"></td><td width="1"></td>
- </tr>
- <tr>
- <td> </td>
- <td colspan="5"><form>
- <table width="641" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="173"><input name="sData" type="text" id="sData">
- by</td>
- <td width="80"><select name="sSelect" id="sSelect">
- <option value="Stu_ID">ID</option>
- <option value="Stu_Name">Name</option>
- <option value="Class_Code">Class</option>
- </select></td>
- <input name="sTable" type="hidden" value="student_recording">
- <td width="72"><input name="search" type="button" onClick="getSearch(sData.value,sSelect.value,sTable.value,'search');" value="Search"></td>
- <td width="316"> </td>
- </tr>
- </table>
- </form></td>
- </tr>
- <tr>
- <td> </td>
- <td colspan="3"> </td>
- <td width="6"> </td>
- <td width="207"> </td>
- </tr>
- <tr>
- <td> </td>
- <td colspan="5" bgcolor="#999999"> </td>
- </tr>
- <tr>
- <td> </td>
- <td colspan="5" bgcolor="#666699"><strong><span class="style1">:: Student Record :: </span></strong></td>
- </tr>
- <tr>
- <td rowspan="4"> </td>
- <td colspan="5"></td>
- </tr>
- <tr>
- <td width="230"><strong>Student Name </strong></td>
- <td width="157"><strong>Contact Number </strong></td>
- <td width="44"><strong>Class</strong></td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td colspan="5"><hr></td>
- </tr>
- <tr>
- <td colspan="5">
- <div id="getResult"></div>
- </td>
- </tr>
- </table>
- </body>
- </html>
Filename : engine.js
Expand|Select|Wrap|Line Numbers
- var xmlHttp;
- function deleteData(paction)
- {
- xmlHttp=GetXmlHttpObject()
- if (xmlHttp==null)
- {
- alert ("Browser does not support HTTP Request")
- return
- }
- var url="../user_access/process.php"
- url=url+"?id="+paction
- url=url+"&sid="+Math.random()
- xmlHttp.onreadystatechange=stateChanged
- xmlHttp.open("GET",url,true)
- xmlHttp.send(null)
- }
- function getSearch(pvalue,ptype,ptable,paction)
- {
- xmlHttp=GetXmlHttpObject()
- if (xmlHttp==null)
- {
- alert ("Browser does not support HTTP Request")
- return
- }
- var url="../user_access/process.php"
- url=url+"?value="+pvalue+"&type="+ptype+"&table="+ptable+"&action="+paction
- url=url+"&sid="+Math.random()
- xmlHttp.onreadystatechange=stateChanged
- xmlHttp.open("GET",url,true)
- xmlHttp.send(null)
- }
- function stateChanged()
- {
- if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
- {
- document.getElementById("getResult").innerHTML=xmlHttp.responseText
- }
- }function GetXmlHttpObject()
- {
- var xmlHttp=null;
- try
- {
- // Firefox, Opera 8.0+, Safari
- xmlHttp=new XMLHttpRequest();
- }
- catch (e)
- {
- //Internet Explorer
- try
- {
- xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (e)
- {
- xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- }
- return xmlHttp;
- }
Filename : process.php
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Untitled Document</title>
- <style type="text/css">
- <!--
- body {
- margin-left: 0px;
- margin-top: 0px;
- margin-right: 0px;
- margin-bottom: 0px;
- }
- .style1 {
- font-size: 18px;
- color: #FFFFFF;
- }
- -->
- </style>
- <script type="text/javascript" src="../admin_sys/engine.js"></script>
- </head>
- <?php
- include("../Database/database.php");
- if($_GET['action'] == "search"){
- showData();
- }else if($_REQUEST['action'] == "Edit"){
- edit();
- }else if($_REQUEST['action'] == "delete"){
- delete();
- }
- function view(){
- global $conn;
- $Viewsql = "SELECT * FROM " . $_REQUEST['Table'] . " WHERE ( " . $_REQUEST['Type'] . "='" . $_REQUEST['sID'] . "')";
- $result = $conn->query($Viewsql);
- while($data = $result->fetch_assoc()){
- echo $data['Stu_ID'];
- echo "<br>";
- echo $data['Stu_Name'];
- echo "<br>";
- echo $data['Stu_Race'];
- }
- }
- function edit(){
- }
- function delete(){
- global $conn;
- $sql="DELETE FROM ".$_GET['table']." WHERE (Stu_ID = ".$_GET['id'].")";
- $conn->query($sql);
- echo "Data Deleted";
- showData();
- }
- function showData(){
- global $conn;
- $sql="SELECT * FROM ".$_GET['table']." WHERE (".$_GET['type']." ='".$_GET['value']."')";
- $result = $conn->query($sql);
- echo "<table width='641' border='0' cellspacing='0' cellpadding='0'>";
- while($data = $result->fetch_assoc()){
- echo "<tr>";
- echo "<td width='230'>" . $data['Stu_Name'] . "</td>";
- echo "<td width='153'>" . $data['Stu_Tel'] . "</td>";
- echo "<td width='22'>" . $data['Class_Code'] . "</td>";
- echo "<td width='48'></td>";
- echo "<td width='188'><div align='right'>";
- echo "<input type='button' onClick='process('delete');' value='Delete'>";
- echo "</div></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td colspan='5'><hr></td>";
- echo "</tr>";
- }
- echo "</table>";
- }
- ?>
can i display the delete button for each record when the record is exist in search_student.php.
Thanks in advance
Bluez