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:
Emailer 1.01 bombs (1997)
[searh] or [shownext]problem (1998)
Listfiles on OSX (2002)
[WebDNA] Libmysql.dll error (2009)
New Weird Behavior (bug report) (2000)
Math, Multiple Equasions and Show/Hide (1998)
W3c Validation (2004)
Locking up with WebCatalog... (1997)
ReadDateFormat (1998)
multi-table date sort problem thingy (2002)
Founditems context returning only 1 item (1997)
[WebDNA] TLS 1.2 and [tcpconnect] (2018)
Image maps/Webcat (1997)
RE: Help name our technology! (1997)
WC2b15 File Corruption (1997)
Hello??? (1997)
showif and cart (1998)
Credit Card Checking?? (1998)
linetiems in thankyou.tpl (1997)
OT: [WAY IN RIGHT FIELD SOMEWHERE] Spam Filters (2005)