delete row

delete row

how to delete row using checkbox and button in php?

localhost=wampserver database name=sourabh table name=sonu and my code is .....

<?php

$link=mysql_connect("localhost", "root", "");
mysql_select_db("sourabh", $link);


$rows=mysql_query("select * from sonu");
$row=mysql_fetch_array($rows);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>delete2</title>
</head>
<form action="delete2.php" method="post" name="delete" >
<table width="100%" border="1">
<tr><td>select</td>
    <td>NAME</td>
    <td>Father NAME</td>
     <td>Date Of Birth</td>
      <td>Mobile</td>
       <td>Email</td>
        <td>Address</td>

  </tr>
  <?php  while($row=mysql_fetch_array($rows))
{  ?>
  <tr>
    <td><input  type="checkbox" name="checkbox[]" id="checkbox[]" value="<?php echo $row['id'];?>"></td>
    <td><?php echo $row['name']; ?></td>
    <td><?php echo $row['fathername']; ?></td>
     <td><?php echo $row['dob']; ?></td>
      <td><?php echo $row['mobile']; ?></td>
       <td><?php echo $row['email']; ?></td>
        <td><?php echo $row['address']; ?></td>

  </tr>
<?php } ?>

</table>
<input type="submit" name="delete" value="delete"  />

<?php 
if(isset($_POST['delete']))
{
    for($i=0;$i<$row;$i++)
    {
    $delete = $checkbox[$i];
    mysql_query("delete from sonu where id='$delete'");

    }
}

?>
</form>
<body>
</body>
</html>
View Answers

September 4, 2012 at 6:05 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()); 
    }
    %>









Related Tutorials/Questions & Answers:
delete row
delete row  how to delete row using checkbox and button in php... if(isset($_POST['delete'])) { for($i=0;$i<$row;$i++) { $delete...("sourabh", $link); $rows=mysql_query("select * from sonu"); $row=mysql
insert and delete a row programmatically
insert and delete a row programmatically  How to insert and delete a row programmatically ? (new feature in JDBC 2.0
Advertisements
sqlite database delete row
sqlite database delete row  How to delete row from SQLite Database?    NSString *updateSQL = [NSString stringWithFormat: @"DELETE FROM aListDB WHERE id='%@'",details.ids
delete row using id
delete row using id  package pkg2; import org.hibernate.Query; import... = "delete from Insurance insurance where id = 2"; Query query = sess.createQuery(hql); int row = query.executeUpdate(); if (row == 0
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
uitableview manually delete row
uitableview manually delete row  uitableview manually delete row   NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; [array removeObjectAtIndex:indexPath.row]; if(![array count]) [indexes addIndex
Delete a row from database by id
Delete a row from database by id  I m creating a small application...) for "DELETE" AND "UPDATE". On clicking delete which is hyper link that particular row.... So anyone will tell me how to give hyper link to Delete and Update and delete
how to delete a row in sql without using delete command.
how to delete a row in sql without using delete command.  how to delete a row in sql without using delete command. thanks in advance
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using checkbox   We are providing you the code where we have specified only three...; st=conn.createStatement(); for(int a=0;a<10;a++){ st.executeUpdate("delete
data grid with edit and delete options at each row.
data grid with edit and delete options at each row.  i want to display the table data in the format of data grid with edit and delete options at each row. i need it very urgently. advance thanks
Hibernate delete a row error - Hibernate
Hibernate delete a row error  Hello, I been try with the hibernate delete example (http://www.roseindia.net/hibernate/hibernate-delete.shtml...(); //======================================= sess = fact.openSession(); String hql = "delete from Contact contact
delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery... [delete from CONTACT] int i=query.executeUpdate
How to delete the row from the Database by using servlet
How to delete the row from the Database by using servlet  Dear Sir/Madam I am trying to delete the one user data in the Oracle SQL server database...: Delete row from database using servlet   In that link solution
Update delete perticular row from brower on link - Struts
Update delete perticular row from brower on link   how can update and delete perticular row from List of employee in brower format are ramesh... delete when i click on update than that perticular row are display on another
JDBC Delete Row In Table Example
JDBC Delete Row In Table Example : In this tutorial we will learn how delete... or more specific  row delete from table that follow any given condition...; delete row then count deleted row and display output "Deleted specific
JDBC ResultSet Delete Row Example
JDBC ResultSet Delete Row Example: Learn how to delete row using ResultSet. We are also used ResultSet object with update capability for delete rows from... for delete the current row form the table of the ResultSet object. Example
include a delete option in every row of table in a JSP page
include a delete option in every row of table in a JSP page  I have the following code of a JSP page........... <blockquote> <p>... on Delete it should delete the particular record from the database and reflect
How to delete the row from the Database by using while loop in servlet
How to delete the row from the Database by using while loop in servlet  Dear Sir/Madam, I am trying to delete the one user data in the Oracle SQL... are USERS (Char), PASS (Varchar2) and CODE (Varchar2). I am trying to delete 4th user
Delete and add row from Table View iPhone
Delete and add row from Table View iPhone In this tutorial will learn how to delete and also how to add row into the table view iPhone, with the help of edit... and Delete buttons on Table view. Table views are commonly found in iPhone applications
Delete row and column from table through java code
Delete row and column from table through java code... will see how to delete row and column from given table through java code. Java code... | +----+----------+------------+---------+ In this table we will delete the row having minimum value of ID then delete
Deleting row and column from a table
Deleting row and column from a table  In this program ,we delete row... connection interface and java driver. After it we can delete row using "delete... the row having minimum ID.  statement.executeUpdate("delete from cellular where id
Delete a Specific Row from a Database Table
Delete a Specific Row from a Database Table   ... in a row, now we need to delete that wrong data. This can be done very easily, and in this section we are going to do the same that is, how to delete a specific row
delete
delete  how delete only one row in the database using jsp.database...;td><input type="button" name="edit" value="Delete" style="background-color..."); Statement st = conn.createStatement(); st.executeUpdate("DELETE FROM employee
JDBC: Delete Record using Prepared Statement
how to delete row of a table using Prepared Statements. Delete Record ... Clause. So you can delete one row or multiple row of table as specified... : Delete Record using PreparedStatement... Row deleted successfully
DELETE
DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL>(SELECT SAL FROM EMP WHERE ENAME='MILLAR') AND ENAME='ALLEN'; THIS IS GIVING THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP
ADD ROW - JSP-Servlet
ADD ROW  Hi Sir, How to use add row and delete row concept in jsp .  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/add-element.shtml Thanks
Deleting a Row from SQL Table Using EJB
are going to delete a row from the SQL Table. Find out the steps given below that describes how to delete a particular row from the database table using EJB... Deleting a Row from SQL Table Using EJB
Delete Account
Delete Account  How to delete account
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
Hibernate delete example program
Hibernate delete example program  How to delete an object in Hibernate? In my program I have to write program to delete the data using Hibernate framework. I want to delete one row of data who's primary key is known to me. What
The DELETE Statement
delhi-5 To Delete a Row  :  Suppose the row with Lname... The DELETE Statement       The DELETE statement is used to delete rows from a table. database will update
delete record
delete record  how to delete record using checkbox and button in php... 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
Sql delete operation
press delete link the appropriate row will be deleted.but i am get this answer...Sql delete operation  Hi, I am tried to several times but i am... yyyy 95643663 update delete 2 aaaa bbbb 64645666
delete query problem - Hibernate
delete query problem  SessionFactory fact = new Configuration... = sess. beginTransaction(); String hql = "delete from STUDENT where name = 'mitha'"; Query query = sess.createQuery(hql) query.executeUpate(); // int row
Grid rows delete issue
event of dropdown also,so if we delete middle row and then remove all rows on onchange of dropdown then because of rows indexing issue,they can't get middle row...Grid rows delete issue  I have a grid having rows with Remove button
To delete post
To delete post  How can I delete my old post answer. I've posted 2 same answers by mistake
Use of delete() method in hibernate.
Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row or multiple row from a table. Here is an example. Example: package
Modifying a single row of database based on selection in jsp
or delete the selected row and update to database.. Please provide me a solution...-and-delete-options-at-each-row-.html http://www.roseindia.net/answers/viewqa/JSP...Modifying a single row of database based on selection in jsp  Hi guys
delete jsp
delete jsp  <%@ page language="java" contentType="text/html...; charset=ISO-8859-1"> <title>Delete Student</title> </head>...;/Controller"> <input type="hidden" name="page" value="delete"/> <
didSelectRowAtIndexPath deselect row
didSelectRowAtIndexPath deselect row  Hi, In my UITableView application when user taps a row, how to deselect row? Thanks
jtable insert row swing
jtable insert row swing  How to insert and refresh row in JTable?   Inserting Rows in a JTable example
ModuleNotFoundError: No module named 'row'
ModuleNotFoundError: No module named 'row'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'row' How to remove the ModuleNotFoundError: No module named 'row' error
ModuleNotFoundError: No module named 'row'
ModuleNotFoundError: No module named 'row'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'row' How to remove the ModuleNotFoundError: No module named 'row' error
Sql row retrieve - SQL
Sql row retrieve  Sir What are the sql statements so that I can retrieve rows from a table by specifying the row numbers such as row no.5 to 10, row no.13 to 20 like that. thanks Pabitra kr debanth. Guwahati. 
hibernate delete query :
NOT NULL , ITEM_ID INTEGER NOT NULL ) I want to delete a row from table... = query.executeUpate(); if(row==0) logger.info("Doesn't delete row. Record...hibernate delete query :   Hi, I m using Hibernate 3 + javadb my
The DELETE Statement, SQL Tutorial
delhi-5 To Delete a Row  :  Suppose the row with Lname="... The DELETE Statement       The DELETE statement is used to delete rows from a table. database will update
JTable duplicate values in row
JTable duplicate values in row  JTable duplicate values in row

Ads