Appending with +1 ...

This WebDNA talk-list message is from

1997


It keeps the original formatting.
numero = 14367
interpreted = N
texte = >Hi, > >I have looked over the past mailings to webcat and I didn't see your db >solution. Could you please resend it directly to me?Hi Kevin,I can't find it either, so I'll write it again:[append db=XXX.db]YYY=[math][search db=XXX.db&neYYYdata=[blank]&deYYYsort=1&YYYtype=num&max=1][founditems][YYY][/fou nditems][/search]+1[/math][/append]Here's what it does. The search context finds all the records in the XXX database that have something (not blank) in the YYY field, then it sorts those records in reverse chronological order so that the record with the largest number in the YYY field is at the top of the results list.Then the Max=1 parameter makes WebCat display only the first record in that list, which is the one with the largest value in the YYY field, right?Then the [math] context adds 1 to the value of that YYY field, thus creating a value of (YYY+1) inside the [math] context. This value is always going to be one whole number larger than the highest number in the YYY field in all the records in the database.Then the [append] context creates a new record in the XXX database, and it sets the value in the YYY field in this new record to the value inside the [math] context, which is one higher than the*previous* high value.That's all ... :)The only thing you have to make sure to do is to NEVER allow anyone to put any values other than NUMBERS into the YYY field. Of course, this should never be a problem if you don't let anyone change these values from a form, or manually by directly accessing the database. Sincerely, Ken Grome WebDNA Solutions http://www.smithmicro.com/webdnasolutions/. Associated Messages, from the most recent to the oldest:

    
>Hi, > >I have looked over the past mailings to webcat and I didn't see your db >solution. Could you please resend it directly to me?Hi Kevin,I can't find it either, so I'll write it again:[append db=XXX.db]YYY=[math][search db=XXX.db&neYYYdata=[blank]&deYYYsort=1&YYYtype=num&max=1][founditems][YYY][/fou nditems][/search]+1[/math][/append]Here's what it does. The search context finds all the records in the XXX database that have something (not blank) in the YYY field, then it sorts those records in reverse chronological order so that the record with the largest number in the YYY field is at the top of the results list.Then the Max=1 parameter makes WebCat display only the first record in that list, which is the one with the largest value in the YYY field, right?Then the [math] context adds 1 to the value of that YYY field, thus creating a value of (YYY+1) inside the [math] context. This value is always going to be one whole number larger than the highest number in the YYY field in all the records in the database.Then the [append] context creates a new record in the XXX database, and it sets the value in the YYY field in this new record to the value inside the [math] context, which is one higher than the*previous* high value.That's all ... :)The only thing you have to make sure to do is to NEVER allow anyone to put any values other than NUMBERS into the YYY field. Of course, this should never be a problem if you don't let anyone change these values from a form, or manually by directly accessing the database. Sincerely, Ken Grome WebDNA Solutions http://www.smithmicro.com/webdnasolutions/. Kenneth Grome

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Error with [applescript] (1999) [SHOWIF AND/OR] (1997) Authentication (2001) Help with database strategy (1998) This list needs a digest: rant, rave... (1997) Aaron kant add (or whatever it was) (2000) Dumb Question about Docs (1997) WebCatalog for guestbook ? (1997) X etc.... (1999) shownext (1997) OT - royalty free images (2002) PCS Frames (1997) using showpage and showcart commands (1996) rotating thumbnails (1997) WebCat b13 CGI -shownext- (1997) Suggestions (1998) Fun with dates (1997) Auto Delete EmailCompleted Files (2002) HELP WITH DATES (1997) Resetting a Formvariable (2000)