Home Answers Viewqa PHP delete row

 
 


sourabh parihar
delete row
1 Answer(s)      9 months ago
Posted in : PHP

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 Pages:
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
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
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 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
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
delete
delete  how delete only one row in the database using jsp.database... type="button" name="edit" value="Delete" style="background-color:red;font-weight... = conn.createStatement(); st.executeUpdate("DELETE FROM employee WHERE empid
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
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
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
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
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
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 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.... 6. Finally call deleteRow() ResultSet method for delete the current row form
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
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
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
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
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... will delete the row having minimum value of ID then delete the column named
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
JDBC: Delete Record using Prepared Statement
JDBC: Delete Record using Prepared Statement In this section, we will discuss 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
The DELETE Statement
The DELETE Statement       The DELETE statement is used to delete rows from a table. database will update...;       DELETE FROM table_name WHERE
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
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
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
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
Deleting a Row from SQL Table Using EJB
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. The steps... Deleting a Row from SQL Table Using EJB   
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
Create Delete Trigger in SQL
'. delimiter $$ CREATE TRIGGER stu_delete before delete ON stu_table FOR EACH ROW... Create Delete Trigger in SQL       Create Delete Trigger in SQL fire this trigger before
dynamic delete and insertion in tables
dynamic delete and insertion in tables  hey... i have a problem..I am... in the table named problem..and a submit solution button besides every row..whenever the admin clicks on the submit button that particular row should be deleted from
The DELETE Statement, SQL Tutorial
The DELETE Statement       The DELETE statement is used to delete rows from a table. database will update...;       DELETE FROM table_name WHERE
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
dynamic delete and insertion in tables
dynamic delete and insertion in tables  hey... i have a problem..I am... in the table named problem..and a submit solution button besides every row..whenever the admin clicks on the submit button that particular row should be deleted from
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
Remove JTable row that read txt file records
a "Delete" button that when select a row and clicked button, row must deleted. But, when i click the button, row dont deleted and a ArrayOutOutBoundsException...Remove JTable row that read txt file records  Hi every one. i have
MySQL PHP Query delete
MySQL PHP Query delete       Mysql PHP Query delete is used to execute Mysql function ( ) delete query from a database table. MySQL PHP Query is used to delete the records
PHP MySQL Delete
PHP MySQL Delete:       In SQL, sometimes we need to delete unwanted records from the table. SQL provides delete statement for this purpose. delete command can be used for delete one or more
MySQL PHP Query delete
MySQL PHP Query delete       Mysql PHP Query delete is used to execute Mysql function ( ) delete query from a database table. MySQL PHP Query is used to delete the records
Hibernate Delete Query
database using the hibernate. Lets first write a java class to delete a row from... (DeleteHQLExample.java), which we will delete a row from the insurance table using the query... Hibernate Delete Query      
Hibernate delete Query
Hibernate delete Query In this tutorial you will learn how to use HQL delete query in Hibernate. In this section we are discussing about the HQL delete query... to use HQL delete query. An example is being given regarding how delete query may
How to delete records from jtabel - Swing AWT
. It is working properly.but now i want to delete rows from tabel at a time one row...How to delete records from jtabel  hello I am using jtabel... to implement row sorting on tabel according column name(ex- date,time and serial
Mysql Trigger After Delete
Employee_Trigger AFTER delete ON employee FOR EACH ROW BEGIN insert into employee... Mysql Trigger After Delete     ... perform Delete Operation on Table. Understand with Example The Tutorial illustrate