|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Deleting the records in a table
hello all,
I display all the records from a table on a form.I used to update the fields and Now, i would like to delete record(s) in a table using the same form. Here it goes how i really want to implement this one: 1.First, i dont want to delete the record in a table in a single-step. 2.(when i displayed the records from a table, i also display a check box at the end of each record). 3.Now, first, i want to check this box and click submit button.when i do this, i want to set a value to this row in the table(I've inserted a column called delete in the table)So, this column will have a value 0 or 1 when this row has been selected to delete. 4.After the value has been set, the form will show two buttons or images which has the values cancel delete or delete the record. so, thatz it. First thing, i would really like to do is to set the value to the delete column when the check box has been checked. The records will be deleted only based on the column(delete), i.e the flag value. If somebody has implemented such an application before, could you pls give me the code, if not atleast something similar to delete the records would be fine.I am able to do it with a simple delete statement in a single step but not in the way how i explained before. For your reference here is my code which hope somebody would be there to give assistance Thanks in advance To this code, i need to implement the delete functionality. php Code:
|
|
#2
|
|||||
|
|||||
|
RE: Deleting the records in a table
Wasn't this answered in: ?
http://codewalkers.com/forum/index....6&realm=default OK, I'm just going to copy out your code below with colour coding on so that it is easier to read - then I'll see if I can modify it where necessary for you. -------- php Code:
|
|
#3
|
|||||
|
|||||
|
RE: Deleting the records in a table
OK, your problem is that all your checkboxes have the same value at the moment, "1". This makes it impossible to determine which checkbox goes with which row.
To modify it, change: php Code:
and I think that should give you the identifier you need to set the delete flag. Then, when the page is returned to itself with the necessary checkboxes ticked, you want code as follows: I shall leave you to write the while() loop (or a for() loop if you prefer) and the query to flag the rows since it will be much easier for you to do it as you have a clearer understanding of the specific table structure than I do. Once you have flagged the relevant rows, it is just a case of running a query such as: By the way, I would recommend reducing your form name to a single word - help prevent errors. |
|
#4
|
|||
|
|||
|
RE: Deleting the records in a table
hello nim,
could you pls help me out further.I cant still do it.My table has the column HS_DELETE.I'm not able to set as a reference: I would be extremely thankful to you if you can help me out with this. thank you once again |
|
#5
|
|||
|
|||
|
RE: Deleting the records in a table
What do you mean by "you can't set it as a reference"?
|
|
#6
|
|||
|
|||
|
RE: Deleting the records in a table
i mean, when i check the check box and submit,the value of the column(HS_DELETE) is not set to 1, i.e the row is not set to delete.
|
|
#7
|
|||||
|
|||||
|
RE: Deleting the records in a table
Sorry, the code I gave you before was wrong. It should have been:
php Code:
Tell me if this works or not. |
|
#8
|
|||
|
|||
|
RE: Deleting the records in a table
hello nim,
sorry to tell you, itz'nt working. It would be so kind of you, if you can append all the modifications in my code.Is this loop correct? Code:
foreach( $HTTP_POST_VARS["delete"] AS $delete => $value ) {
if ( $value == "on" )
Thanks for helping me out. |
|
#9
|
|||
|
|||
|
RE: Deleting the records in a table
hmmm... At the moment, that loop is checking each checkbox to see whether it is checked or not. If I am reading it correctly, the $delete variable should contain a matching value to $cntr, which you have used as your row ID. Can you not use this information to update the database as necessary?
What did the code I gave you before actually do? Did it return any errors? Did it add anything to the table? Try putting this code below the line which reads "$update_results = ibase_query($sql);" : This will cause any MySQL errors to be returned to the page. |
|
#10
|
|||||
|
|||||
|
RE: Deleting the records in a table
i am not able to display anything now.I doubt if this is in order.
Before, it was working fine, atleast i was able to display the records from the table,but now, itz blank. since, i am using interbase as my database,i checked out with ibase_errmsg(),it does'nt show anything.I think the loop is not properly handled. Thanks for your great attention Nim. php Code:
|
|
#11
|
|||
|
|||
|
RE: Deleting the records in a table
I'm really not sure then. If there is someone round here with a bit more Database experience than me they can probably help you - I've only been using MySQL for about 3 weeks... Makes me wonder how I've got a working search engine for the competition - just a bit more tweaking and it'll be done.
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Deleting the records in a table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|