delete record

Ads
 

delete record

how to delete record using checkbox and button in php

View Answers

September 4, 2012 at 6:06 PM

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 of id of table. When the user selects the particular checkbox, that row will get deleted from the database. In the database we have created three fields bookid,author and title in the database.

1) Create book.jsp

<%@page import="java.sql.*"%>

<form name=myname method=post action="delete.jsp">
<table border="1">
<tr><td></td>
<td><b><u>bookid</u></b></td>
<td><b><u>Author</u></b></td>
<td><b><u>title</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from book");
int i=0; while(rs.next()){ %>
<tr><td><input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid") %>></td>
<td><%= rs.getString("bookid") %></td>
<td><%= rs.getString("author") %></td>
<td><%= rs.getString("title") %></td>
</tr><%
i++;
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<input type="submit">
</form>

2) Create delete.jsp

<%@page import="java.sql.*"%>

<%String id[]= new String[10];
for(int i=0;i<10;i++){
id[i]=request.getParameter("check"+i);
out.println(id[i]);
}
%>

<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
st.executeUpdate("delete from book where bookid='"+id[a]+"'");

}
}catch(SQLException e){ 
    System.out.println(e.getMessage()); 
    }
    %>

Ads









Related Tutorials/Questions & Answers:
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...=conn.createStatement(); for(int a=0;a<10;a++){ st.executeUpdate("delete from book where
Hibernate Delete Query
In this section we will discuss how to delete record of table using HQL
Advertisements
hibernate delete orphan
In this section, you will learn to delete mapped record using cascade delete-orphan in Hibernate
JDBC: Delete Record using Prepared Statement
JDBC: Delete Record using Prepared Statement In this section, we will discuss... statement. You can delete any specific record under some condition using WHERE... { // Delete record String sql = "DELETE FROM student WHERE roll
JSP Delete Record From Table Using MySQL
JSP Delete Record From Table Using MySQL This tutorial explains you that how.... In this tutorial you will learn that how to delete a record of a database table in JSP. In this example we will discuss about how to delete a record of database table
Delete All Records
Delete All Records       In this section, you will learn how to delete all record using jpa...(); Query query=em.createQuery("DELETE FROM Student st"); int
JDBC Delete Statement Example
.style1 { text-align: center; } JDBC Delete statement Example A JDBC delete statement deletes the particular record of the table. At first create... query = "DELETE FROM student WHERE RollNo=1"; // Updating Table
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 jsp
;<br/> <input type="submit" value="Delete record"/></center>...delete jsp  <%@ page language="java" contentType="text/html...; charset=ISO-8859-1"> <title>Delete Student</title> </head>
Delete Account
Delete Account  How to delete account
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
Delete a Records in Database
; The delete query is used to delete the record from table country  followed... Delete a Records in Database       The Delete Statement is used to delete the records and rows
Create Delete Trigger in SQL
Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before the DELETE operation is executed. Understand with Example
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
To delete post
To delete post  How can I delete my old post answer. I've posted 2 same answers by mistake
Create Delete Trigger in SQL
Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before the DELETE operation is executed. Understand with Example
Use of delete() method in hibernate.
Department and the deptId. Now you can delete record by calling delete method...Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row
How to delete objects using Hibernate?
How to delete objects using Hibernate?  Hi, How to delete objects using Hibernate? I want to delete an object (record) in table. Thanks   Hi, Hibernate Session API provides function to delete object. For deleting
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
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
delete row
delete row  how to delete row using checkbox and button in php...="delete" > <table width="100%" border="1"> <tr><td>...;/table> <input type="submit" name="delete" value="delete" /> <?php
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
delete() method of hibernate
delete() method of hibernate  Define the use of delete() method of hibernate? Example
delete javascript object
delete javascript object  How to create and delete an object in JavaScript
hibernate delete query :
= query.executeUpate(); if(row==0) logger.info("Doesn't delete row. Record...hibernate delete query :   Hi, I m using Hibernate 3 + javadb my... NOT NULL , ITEM_ID INTEGER NOT NULL ) I want to delete a row from table
Problem in record viewing in jsp - JSP-Servlet
Problem in record viewing in jsp  hai i have developed the application using jsp,servlets in eclipse ide i have to insert,delete,update and view... it is i cannot view the record after eclipse ide is closed and reopen
ModuleNotFoundError: No module named 'code-record'
ModuleNotFoundError: No module named 'code-record'  Hi, My Python... 'code-record' How to remove the ModuleNotFoundError: No module named 'code-record' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'django-record'
ModuleNotFoundError: No module named 'django-record'  Hi, My... 'django-record' How to remove the ModuleNotFoundError: No module named 'django-record' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'docker-record'
ModuleNotFoundError: No module named 'docker-record'  Hi, My... 'docker-record' How to remove the ModuleNotFoundError: No module named 'docker-record' error? Thanks   Hi, In your python

Ads