The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 2 of 2

Thread: Insert then delete Data

  1. #1

    Insert then delete Data

    i have a form that inserts the form data into a table (pending_tbl) and all pending are outputted in a list with accept button, when you click the accept button it populates a form with the details for viewing, if all is ok you click submit and it inserts this into another table (members_tbl) this works but what i need it to do is once it inserts the data into members_tbl it deletes it from pending_tbl.

    Who is this done?

  2. #2
    just run a DELETE statement. so something like:
    Code:
    DELETE FROM pending_tbl WHERE pending_id IN ( 1, 2, 3, 4 )
    so that would delete everything in pending_tbl where the pending_id (assuming that was your id column) is 1, 2, 3, or 4.

    if you want it more advanced, i would probably do something like this for each record:
    Code:
    INSERT INTO members_tbl
    FROM pending_tbl
    WHERE pending_tbl.pending_id = 1;
    
    UPDATE pending_tbl
    SET members_id = LAST_INSERT_ID(),
    members_date = NOW()
    WHERE pending_id = 1;
    so that would require you to have 2 additional columns in pending_tbl: members_id and members_date. members_id would reference the id number assigned to the transferred record. members_date would just track what day the transfer was made.

    i would probably have the records in pending expire after like 2 days post-transfer. that way, if there are any problems you can go back to the pending table and reconcile the issues. but you're not keeping the additional data around for too long.

    clearly then, you would only be able to approve pending_id numbers where the members_id IS NULL.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012