Edit the record.

Ads
 

Edit the record.

sir, I have a table consist of huge data.I have displayed that data.side of them there is an edit button which will edit that particular record.after editing the data i want to edit another row which is next to previous edited row or edit the previous record of the previously edited row.Consider this is a huge database.and there are sorted according to their name or some email.according to the sorted page we should fetch the data and edit it(previous and next).And also it should have first and next where it will give corresponding page first or last record.This should be done in PHP.

View Answers

August 10, 2011 at 11:25 AM

We are sending you a jsp edit application. It will be helpful for you.

1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><input type="button" name="edit" value="Edit" style="background-color:green;font-weight:bold;color:white;" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>

August 10, 2011 at 11:26 AM

continue..

3)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>

August 10, 2011 at 4:49 PM

But it should be done through PHP???

Ads









Related Tutorials/Questions & Answers:
Edit the record.
Edit the record.  sir, I have a table consist of huge data.I have displayed that data.side of them there is an edit button which will edit... to previous edited row or edit the previous record of the previously edited
edit data
edit data  sir i want to do edit a particular customers information after he logs in, i am also using sessions. thank you
Advertisements
Edit Distance
Edit Distance  I want java programming ask from user input two string and the program find the edit distance between two strings and find table and optimal solution using GUI
record management application - Java Beginners
record management application  write a small record management application for a school.Tasks will be Add record, Edit record,Delete record, List records. Each record contains: name(max 100 char), Age,Notes(No Max.Limit
delete record
delete record  how to delete record using checkbox and button in php   We are providing you the jsp code that displays the database table data into the html table. Along each table row there is a checkbox consists
ModuleNotFoundError: No module named 'edit'
ModuleNotFoundError: No module named 'edit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'edit' How to remove the ModuleNotFoundError: No module named 'edit' error
ModuleNotFoundError: No module named 'edit'
ModuleNotFoundError: No module named 'edit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'edit' How to remove the ModuleNotFoundError: No module named 'edit' error
ModuleNotFoundError: No module named 'edit'
ModuleNotFoundError: No module named 'edit'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'edit' How to remove the ModuleNotFoundError: No module named 'edit' error
ModuleNotFoundError: No module named 'Record'
ModuleNotFoundError: No module named 'Record'  Hi, My Python... 'Record' How to remove the ModuleNotFoundError: No module named 'Record'... to install padas library. You can install Record python with following command
Update / Edit data
Update / Edit data  Hello, i want to create a page to edit or update... record, all the field will be filled with data from the database base... consists of that particular id. When the user clicks the particular edit button
next and previous record in php
next and previous record in php  How to display next and previous records in PHP
Jsp code for disabling record.
Jsp code for disabling record.  I want a Jsp and servlet code for the mentioned scenario. Q. A cross sign appears in front of each record, click to disable the record.System marks the record as disabled.The record
Acess Record from database.
Acess Record from database.  How to access records from database and how to display it on view page, with the help of hibernate
Edit cron entry
Edit cron entry   Hi, What is the command to Edit cron entry in linux? Regards Deepak Kumar   Hi, You can use the following command to open cron configuration in vi editor: crontab -e After editing just save
importing data and edit that data
importing data and edit that data   hello sir i have data in excel sheet which contain 2 rows and i want to import that data to ms access and edit that data like adding new columns and new rows and creating new tables
UINavigationBar Edit Button
UINavigationBar Edit Button  UINavigationBar Edit Button Given is the code that adds a edit button item as a nav bar item in your UINavigation Controller. -(void)viewDidLoad; { [super viewDidLoad]; UINavigationBar* navBar
uitableview edit done button
uitableview edit done button  How to add Edit / Done button in UITableView with an action on click?   UITableview Edit done Button To add " Edit / Done button " in UITableView add the given code in UIView Controller
retrieve record from table
retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually
Record and Save Video using Java
Record and Save Video using Java  How to record video(webcam) and save it using Java.?? Its really urgent
ModuleNotFoundError: No module named 'apyref-edit'
ModuleNotFoundError: No module named 'apyref-edit'  Hi, My Python... 'apyref-edit' How to remove the ModuleNotFoundError: No module named 'apyref-edit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'config_edit'
ModuleNotFoundError: No module named 'config_edit'  Hi, My Python... 'config_edit' How to remove the ModuleNotFoundError: No module named 'config_edit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'config_edit'
ModuleNotFoundError: No module named 'config_edit'  Hi, My Python... 'config_edit' How to remove the ModuleNotFoundError: No module named 'config_edit' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'dir-edit'
ModuleNotFoundError: No module named 'dir-edit'  Hi, My Python...-edit' How to remove the ModuleNotFoundError: No module named 'dir-edit... to install padas library. You can install dir-edit python with following
ModuleNotFoundError: No module named 'dvha-edit'
ModuleNotFoundError: No module named 'dvha-edit'  Hi, My Python... 'dvha-edit' How to remove the ModuleNotFoundError: No module named 'dvha-edit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'edit-distance'
ModuleNotFoundError: No module named 'edit-distance'  Hi, My... 'edit-distance' How to remove the ModuleNotFoundError: No module named 'edit-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edit-distance-lte1'
ModuleNotFoundError: No module named 'edit-distance-lte1'  Hi, My... named 'edit-distance-lte1' How to remove the ModuleNotFoundError: No module named 'edit-distance-lte1' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'edit-distance'
ModuleNotFoundError: No module named 'edit-distance'  Hi, My... 'edit-distance' How to remove the ModuleNotFoundError: No module named 'edit-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edit-distance-lte1'
ModuleNotFoundError: No module named 'edit-distance-lte1'  Hi, My... named 'edit-distance-lte1' How to remove the ModuleNotFoundError: No module named 'edit-distance-lte1' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'hwit-edit'
ModuleNotFoundError: No module named 'hwit-edit'  Hi, My Python... 'hwit-edit' How to remove the ModuleNotFoundError: No module named 'hwit-edit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'jaml-edit'
ModuleNotFoundError: No module named 'jaml-edit'  Hi, My Python... 'jaml-edit' How to remove the ModuleNotFoundError: No module named 'jaml-edit' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'mem-edit'
ModuleNotFoundError: No module named 'mem-edit'  Hi, My Python...-edit' How to remove the ModuleNotFoundError: No module named 'mem-edit... to install padas library. You can install mem-edit python with following

Ads