Validation ina multi record form ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
markwenham
Forum Newbie
Posts: 13
Joined: Fri Aug 16, 2002 11:33 pm

Validation ina multi record form ...

Post by markwenham »

I am trying to design a form that has the following qualities

1. It can be multi-record depending upon number of rows in the db. I use
variable variables to do this.
2. It can be used to edit and update the rows.

The above is fine and works ok but I want to add

3. Server validation with PHP. If there is a problem with validation then I
want to re-present the form with the originally posted values.This is fairly
easy to do with a single record form by submitting the form to itself, BUT
doing this with a variable number of records is confusing me big time!!

Can anyone pass on their experiences with doing this sort of thing or
suggest the pseudo code.

Thanks, Mark
8O
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post by gotDNS »

I'm going to bed now...i think i can help you tomorrow...
markwenham
Forum Newbie
Posts: 13
Joined: Fri Aug 16, 2002 11:33 pm

Post by markwenham »

sounds good, thanks
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

assuming you use $_POST to transfer these variables

look into foreach().. you can pass each variable in post back to the form, or do what you want.
markwenham
Forum Newbie
Posts: 13
Joined: Fri Aug 16, 2002 11:33 pm

Post by markwenham »

Hmmm...

When I query the db I get say 3 records returned, each with 4 fields. I name the fields like this, where the trailing number relates to the record

ref0 fname0 sname0 tel0
ref1 fname1 sname1 tel1
ref2 fname2 sname2 tel2

These are obviously the keys that end up in the $_POST array once the form is posted.

Now what is confusing me is how I can reload the original page in the same format with posted values, should the validation not take place correctly. I guess my question also relates to how I can lay out the newly returned page. In the original page I use a loop with mysql_fetch_assoc to format one table row for each record returned.

In the newly returned page after unsuccesful validation all I have is the $_POST array which does not make a "per record" distinction. I guess I could use some type of substr to grab the number from the end of the item and format around that, but it seems clumsy. ??

Thanks, Mark
Post Reply