473,378 Members | 1,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Processing an unknown number of POST variables to a DB

Hi.. I'm having a problem trying to figure out the best way to
process a POST and add items to my database, and hope someone can help
me... :)

Background:
I have a database that I will use to hold Purchases of Items

Each Item purchased is stored in it's own record:
[item_name][item_number][item_price]....etc...

Orders come in via a POST from a Third Party, over which I have no
control.

In the POST... if there's multiple items that have been purchased,
numbers are appended to the POST variables... i.e. item_name1,
item_name2...etc.

My problem:

Since I don't know beforehand how many items will be included in a
POST, how do I write the code to process the POST and split it up
into individual items to insert into the database, without writing a
lot of extraneous code?

Right now, the only way I can think of doing this is going through the
POST and checking for lots of things that may or may not exist by
checking:

is there an item_name 1... if so, add a record for item_name,
item_number.....etc

is there an item_name 2....if so, insert a record for item_name,
item_number...etc....
...............
is there an item_name100.... if so....

I'm aware that I can use a "For Each" to get all the records out of
the POST... but not knowing which variables will or will not exist, I
would still have to check manually for each one... or so it seems...

I know there must be a good way to do this... but have no idea what it
might be... Can someone please help?? :)

Thanks,

Sarah



Jul 19 '05 #1
1 3017
Dim parrItems
parrItems = Split(POSTMESSAGE, "DELIMETER")

Dim pstrLastItemName
pstrlastItemName = parrItems(UBound(parrItems))

'Now parse the lat item name after the last '_' to find the number - this
will be number of item groups posted.
plngNumberOfGroups = [Number that is after the last '_' in the item name]
Now you can do:

plngItemsInEachGroup = CLng(UBound(parrItems) / plngNumberOfGroups)

For i = 1 to plngNumber of Groups
'This constitutes a record (eg. all the same ending number).
For j = 1 to plngItemsInEachGroup
'This is each item in the group / record.
Next
Next

Of course, this assumes that the number of items in each group / record is
the same.

Chris.

"sarah" <ud*****@soawa.com> wrote in message
news:l8********************************@4ax.com...
Hi.. I'm having a problem trying to figure out the best way to
process a POST and add items to my database, and hope someone can help
me... :)

Background:
I have a database that I will use to hold Purchases of Items

Each Item purchased is stored in it's own record:
[item_name][item_number][item_price]....etc...

Orders come in via a POST from a Third Party, over which I have no
control.

In the POST... if there's multiple items that have been purchased,
numbers are appended to the POST variables... i.e. item_name1,
item_name2...etc.

My problem:

Since I don't know beforehand how many items will be included in a
POST, how do I write the code to process the POST and split it up
into individual items to insert into the database, without writing a
lot of extraneous code?

Right now, the only way I can think of doing this is going through the
POST and checking for lots of things that may or may not exist by
checking:

is there an item_name 1... if so, add a record for item_name,
item_number.....etc

is there an item_name 2....if so, insert a record for item_name,
item_number...etc....
..............
is there an item_name100.... if so....

I'm aware that I can use a "For Each" to get all the records out of
the POST... but not knowing which variables will or will not exist, I
would still have to check manually for each one... or so it seems...

I know there must be a good way to do this... but have no idea what it
might be... Can someone please help?? :)

Thanks,

Sarah


Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Leester | last post by:
Hi, Can anyone tell me if it is possible to generate the actual URL of the current PHP script (with all POST data included)? I have a third-party application that I'd like to use to see HTTP...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
9
by: Arnold | last post by:
I need to read a binary file and store it into a buffer in memory (system has large amount of RAM, 2GB+) then pass it to a function. The function accepts input as 32 bit unsigned longs (DWORD). I...
122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
by: jimwawar | last post by:
Hi, I am using Mircosoft Visual C++ 6.0. I am reading in a line from a .dat file using fgets. The line is an unknown number of variables written in scientific notation (4.20000e+00 1.00000e-01 ...
1
by: Xah Lee | last post by:
Text Processing with Emacs Lisp Xah Lee, 2007-10-29 This page gives a outline of how to use emacs lisp to do text processing, using a specific real-world problem as example. If you don't know...
5
by: imailz | last post by:
Hi all, since I'm forced to switch from Fortran to C I wonder if there is posibility in C: 1) to use implicit loops 2) to parse several variables which number is determined at runtime. ...
9
by: oldyork90 | last post by:
I'm going thru code and have never seen this before http://www.webreference.com/programming/javascript/mk/column2/3.html Look at function CreateDragContainer() on line 25. It has no arguments...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.