Re: SKU lookup
This WebDNA talk-list message is from 1997
It keeps the original formatting.
numero = 13100
interpreted = N
texte = At 12:38 AM 8/21/97, you wrote:>Hello>>Hey how would one write an expression to lookup the last SKU entry made>in a given db, and then add 1 to it, and enter that automatically in the>SKU field?>-- As Ken mentions, the [cart] is great for generating unique skus. However,sometimes you might require a unique sku which is not a random number suchas 8721054256023 which is the sort of number you get by using [cart].For example, what if you are making an employee database and you want totrack it using a logical progression (1, 2, 3 etc.) with each newemployee's number being one higher than the last.Here is a snippet of code to take the highest sku value from a database andthen increment it by one:[search db=yourdatabase.db&grskudata=0&skusort=1][founditems][name][math]newsku=[sku][/math][/founditems][/search][math]newsku=(newsku+1)[/math]
Final value=[math]newsku[/math]
To hide the output from a [math][/math] context just enclose it like soThis lets the code get parsed without displaying the results.To call the newsku value elsewhere in the template just use[math]newsku[/math].....................................................................W O R L D P O I N T I N T E R A C T I V E DANIEL CAMERON web engineerHonolulu San Francisco 2800 woodlawn drive 222 sutter street dcameron@worldpoint.com suite 170 sixth floor www.worldpoint.com honolulu, hi 96822 san francisco, ca 94108 voice.808.539.3932 fax.808.539.3943 cell.808.291.1610.....................................................................
Associated Messages, from the most recent to the oldest:
At 12:38 AM 8/21/97, you wrote:>Hello>>Hey how would one write an expression to lookup the last SKU entry made>in a given db, and then add 1 to it, and enter that automatically in the>SKU field?>-- As Ken mentions, the
[cart] is great for generating unique skus. However,sometimes you might require a unique sku which is not a random number suchas 8721054256023 which is the sort of number you get by using
[cart].For example, what if you are making an employee database and you want totrack it using a logical progression (1, 2, 3 etc.) with each newemployee's number being one higher than the last.Here is a snippet of code to take the highest sku value from a database andthen increment it by one:[search db=yourdatabase.db&grskudata=0&skusort=1]
[founditems][name]
[math]newsku=[sku][/math][/founditems][/search]
[math]newsku=(newsku+1)[/math]
Final value=[math]newsku[/math]
To hide the output from a
[math][/math] context just enclose it like so[math]newsku=[sku][/math]>This lets the code get parsed without displaying the results.To call the newsku value elsewhere in the template just use
[math]newsku[/math].....................................................................W O R L D P O I N T I N T E R A C T I V E DANIEL CAMERON web engineerHonolulu San Francisco 2800 woodlawn drive 222 sutter street dcameron@worldpoint.com suite 170 sixth floor www.worldpoint.com honolulu, hi 96822 san francisco, ca 94108 voice.808.539.3932 fax.808.539.3943 cell.808.291.1610.....................................................................
Daniel Cameron
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:
RE: strip .0 off off IPaddress (1999)
WebDNA 4.5.1 Now Available (2003)
WebCatalog - Mac vs Linux (2000)
WebCatalog f2 Installation (1997)
Configuring E-mail (1997)
BR (1997)
WebCat editing, SiteGuard WAS:SiteAssociative lookup style? (1997)
Autoreturn Submit? (1997)
Listfiles not listing mounted volume (2002)
[sendmail] on NT? (1997)
getchars broken? (1997)
Multiple prices (1997)
Emailer+NetTen [same machine]=? (2000)
SKU (1997)
Execute Applescript (1997)
WebCat2 - Getting to the browser's username/password data (1997)
Searching (2000)
Help name our technology! (1997)
OT: Way off-topic: Qmail and Linux (2003)
TIP OF THE DAY (2004)