I want to delete a specific row from the Mysql database; which is been selected using checkbox. Now my problem is that; I am executing a query (select * from table_name where Account_No='100') . so when I execute this query ; it shows me the Account having Account_No=100. Now by selecting this row using the checkbox i want to delete it ; but couldn't find a way to do so......... Can anyone please help me out....... thanks in advance......
Thank you ! Mr. Bear Bibeault for your quick reply.. The concept is kind of clear to me now. but just wanted to tell you ; that I don't have any code in jsp. Here is code fragment....
now this page takes an Account Number from user and request is sent to 'search servlet' given below..
so when execute this program ; it returns an account having the account no. entered by user. which looks like this....(image attached..) now when i select this row...
by clicking on delete button I want to delete this row...so what would you suggest sir! thank you!!
That is simple!
When you build you second form, you must to have hidden html input text field with information like "id" or any other that you need for do Delete query in mysql.
Then when you press the delete button, it must submit all this data to other servlet (a servlet for delete).
Other thing: in my opinion you dont need the check box!! if you have only one register in the table.!
Ok, that all. Let me know if you have problem with my explanation.
Joined: Feb 06, 2012
thanks Mr. jhon ! yes , I understood the idea that you propose...what I didnt got is that what you saying regarding not having checkbox ;can you please make it clear .... also do i need to use request.getParametervalues() to get all the values in a selected row . What would you say? thanks in advance :beerchug:
I believe you must be using some key (id,name) based on which your records are deleted. So, what you can do is you can make this key as the value of the check box. Now in the servlet you can use the following code.
The only thing you need to make sure is name of all the checkboxes are same in the page.
Joined: Feb 06, 2012
thank you very much !!! swastik dey! thats what i was thinking to do but wasnt sure . thanks for the advice...........