I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record.
Filename : search_student. php -
<?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 -
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 -
<!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>";
-
}
-
?>
-
Im getting error if i put input type='button' onClick='proces s('delete');' value='Delete'> "; in process.php. I know my design structure is not correct. Can anyone get me an idea about the correct way to design.
can i display the delete button for each record when the record is exist in search_student. php.
Thanks in advance
Bluez
3 3426 acoder 16,027
Recognized Expert Moderator MVP
The reason why you're getting an error is that you've got a quote within a quote. Javascript thinks the quote has ended and then comes across the word 'delete' which it obviously doesn't understand.
You have two options: either escape the quotes using backslash (\) or use single and double quotes together, e.g.
[HTML]<input type='button' onClick="proces s('delete');" value='Delete'>[/HTML]
Thx..it's work
and sorry for the late reply
acoder 16,027
Recognized Expert Moderator MVP
Thx..it's work
and sorry for the late reply
No problem. Glad you got it working.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: darrel |
last post by:
Anyone using Ajax with .net? Are there any controls/tools that make building
with ajax easier or is it, for now, just a matter of connecting the
javascript to the back end manually as needed?
-Darrel
|
by: Alex |
last post by:
Example uploaded to:
http://www.clickatus.com/ajax/
BTW - This is for FIREFOX, won't work in IE.
I don't know why but when it is executed the browser still in loading
state... Even though XMLHttpRequest already got its string from the
server...
Any help?
|
by: caston |
last post by:
Well, everybody can now agree with the fact that the Ajax hype is over.
Still multiple Ajax Frameworks are flourishing, aren't they?
So, last night I questioned myself with the following: "When Ajax
Frameworks will be gone? What is required to get rid of them and start
using browsers?" (To be more precise, I should probably also mention
what kind of frameworks do i mean. These are: Dojo, BackBase, Qooxdoo
etc.)
I've got an answer that I...
|
by: Free Ebooks |
last post by:
81 AJAX and 24 JavaScript Ebooks
Here are some of the AJAX topics and areas covered by these ebooks:
Rails and AJAX
Building Ajax Web Applications
Creating Ajax Web Pages
Ajax Patterns
Ajax Tutorial
Ajax Best Practices
Ajax XMLHttpRequest and Struts
|
by: Nathan Sokalski |
last post by:
I am moving my website from my machine to my webhost, and need some help
with what extra files I need to include due to the fact that I used AJAX in
my site. Everything on the site is obviously functioning as desired when I
test it on my machine using Visual Studio 2005. From what I have determined,
the files I am forgetting are the JavaScript files from the Microsoft AJAX
Library (See "To install Microsoft AJAX Library" at the bottom of...
| |
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= |
last post by:
I'm about to finally make the jump and start a new site using AJAX. THe
question i have for all of you AJAX developers out there is which one?
1. The Standard AJAX frame work
2. The Tool kit.
3. Or are there others out there.
4. Should i not do AJAX at all because it still posts back the entire page
even though
only the section is refreshed. (someone tell me i'm wrong here and why
please!)
|
by: =?Utf-8?B?R2VyaGFyZA==?= |
last post by:
I am just stating to use ajax, and have a perfect place to use the accordion
control. I have it working fine, but need to have a normal asp button in one
of the panes that fires an onclick event as normal. The button works fine
outside of the pane, but once I put it in the pane it no longer fires the
event. How can I get a button in the accordion to run a function on the
server on the onclick event?
Thanks.
|
by: Joe |
last post by:
I added some ajax to my asp.net web site and will Ajax just doesn't seem
to work. Does Any one PLEASE have any ideas on why Ajax doesn't work
on Apache 2.2.6 w/asp.net 2.0
|
by: zalek |
last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET",
url, false).
I noticed that in FireFox handler doesn't starts. It starts when I use
xmlHttp.open("GET", url,true).
I need to use it in sync mode. Any ideas what can I do?
Thanks,
Zalek.
|
by: Scott M. |
last post by:
What is the version number of AJAX when we talk about ASP .NET AJAX in VS
2008?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |