PDA

View Full Version : different data into different tables


aldredd
11-22-2004, 05:36 AM
In my database, I have several tables.
Most data is entered into just the one table from the opening page, which is all fine, but sometimes, the user will tick a box which means more info needs to be entered.

When submitted, depending on the 'department' chosen by the user on the first page, the next page will display a number of text forms. These options are pulled off from the database

So on the previous page, they selcted department a), the next page then uses that department code (always a number), then matches that with the possable errors for that department (tblDECodes). These are put into a form as text boxes. The value is the error code, and the name is pulled off the table tblErrorCodes.

tblDECodes tblErrorCodes

DeptID - ErrorCode ErrorCode - Name
1 - 3 1 - damage
1 - 5 2 - missing
2 - 3 3 - Extra
2 - 4

Okay so far..

The user then enters however many there are for each error (often 0) and submits it.

This is where I have problems.

The original data from the first page gets put into the table tblQAuditsHD, but what I need to somehow do, is find out which of the text boxes have had data entered into them - which is a bugger, cos there is no telling what form names there will be, and then enter both the error code, and it's corresponding total into table tblQAuditsDT. And, if that wasn't bad enough, when the data is put into tblQAuditsHd, it's assign it's unique number QAID. When the error codes are put into tblQAuditsDT, it needs to have the QAID assigned to it - entered in that table too.

tblQAuditsHDt

QAID - ErrorCode - Count
565 - 1 - 2
573 - 3 - 1



I hope you're able to help, as I've hit a dead end. :confused:

If you need to view / access the code, db or whatever, let me know, and I'll see what I can do :o)
Many thanks,
David Aldred

Roy Sinclair
11-30-2004, 07:41 PM
You can put the QAID gotten while processing the first page into a hidden form field on second page or into a "Session variable" (sessions don't scale well so they're not recommended for high volume sites though they're perfectly fine for sites that don't get heavy traffic).

That QAID can be used to retrieve the data saved from the first page and depending on what is present in that data you may be able to determine which fields may be present on the second page but even if the data won't help with that you can also iterate through all the form fields on the second page and process them. The following example code will print out all the fields from a form and their value:


For GET data:

For each returnedQuery in Request.Querystring
response.write returnedQuery & " = " & Request.Querystring(returnedQuery) & "<br />"
Next

For POST data

For each returnedQuery in Request.Form
response.write returnedQuery & " = " & Request.Form(returnedQuery) & "<br />"
Next