Forums
This topic is locked
Batch Delete (basic-ultradev)
17 Dec 2001 17:05:37 Peter R posted:
Hello all,I'm trying to make a page where I can make multiple deletes via check boxes. I followed the mini-tutorial at basic_ultradev: www.basic-ultradev.com/articles/FormFieldTricks/index.asp
I must have done something wrong because my implementation only deletes 1 checked record instead of multiple like it's supposed to.
Does this sound like the correct way to accomplish multiple deletes:
1: I created a standard "Results" page but with the Repeat region inside a form field.
2: I included in the Repeat region a few fields from my table, and a checkbox named "checkbox".
3: I dragged my sale_id field from the Data-Bindings palette and dropped it on the checkbox.
4<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle> then placed a submit button in the form, and made the forms Action: point to a Delete-Page with the Method: Get.
5<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle> created the Delete-Page and placed a recordset in it with the following SQL:
DELETE from sale_tracker WHERE sale_id IN (MyCheckbox)
Name Default Value Run-Time Value
MyCheckbox checkbox $checkbox
From what I understand, the form is supposed to pass the sale_id values to the Delete-Page seperated by commas like 29083, 19289, 21039 and the SQL would delete each record with these sale_id's.
But for some reason, my implementation only deletes one record even if several are selected.
Any idea why this isn't working right?
I'm using MySQL and PHP.
Thank you.
Peter
Replies
Replied 17 Dec 2001 17:48:40
17 Dec 2001 17:48:40 Joel Martinez replied:
hmm, odd... there are only a few things I can think of.
1. before running the sql statement, print the value of the checkbox name to the page, see if it is in fact separated by comas.
2. if it is, and there are spaces after the commas, try to get rid of the spaces (replace spaces with "", sorry, don't know the syntax in PHP)
That's the only thing I can think of at this point.
if you are still having a problem, print out the value of the entire sql statement string before it is executed, and post that back here.
Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
1. before running the sql statement, print the value of the checkbox name to the page, see if it is in fact separated by comas.
2. if it is, and there are spaces after the commas, try to get rid of the spaces (replace spaces with "", sorry, don't know the syntax in PHP)
That's the only thing I can think of at this point.
if you are still having a problem, print out the value of the entire sql statement string before it is executed, and post that back here.
Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
Replied 17 Dec 2001 20:50:04
17 Dec 2001 20:50:04 Peter R replied:
Hey Joel,
Don't worry, I don't know PHP syntax yet either! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> I'm brand new to this so everythings a struggle. I'm not even sure how to print the value of the checkbox to the page to be quite honest. Some simple one line code I'm sure...
After submitting the "Results" form to the Delete-Page, at least in the address bar it reads:
/saletrackerMdeleted.php?Submit=DELETE+%22Checked%22+Records&checkbox=00001&checkbox=00004
00001 and 00004 are the records that should be getting deleted, so atleast I know they're both arriving at the delete page. As for the commas, I'm not sure yet. Will let you know when I find out..
Peter
Don't worry, I don't know PHP syntax yet either! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> I'm brand new to this so everythings a struggle. I'm not even sure how to print the value of the checkbox to the page to be quite honest. Some simple one line code I'm sure...
After submitting the "Results" form to the Delete-Page, at least in the address bar it reads:
/saletrackerMdeleted.php?Submit=DELETE+%22Checked%22+Records&checkbox=00001&checkbox=00004
00001 and 00004 are the records that should be getting deleted, so atleast I know they're both arriving at the delete page. As for the commas, I'm not sure yet. Will let you know when I find out..
Peter
Replied 17 Dec 2001 21:15:35
17 Dec 2001 21:15:35 Joel Martinez replied:
try posting in the PHP forum
Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/