Re: [WebDNA] PHP Array translated to Webdna
This WebDNA talk-list message is from 2010
It keeps the original formatting.
numero = 104583
interpreted = N
texte = Exactly translated to webdna, it goes a bit like this[function name=combobox][showif [_name]=country][text]jsonResult=1[/text][showif [_value]=3][return][{"1":"New York"},{"2":"Montana"},{"3":"Texas"}][/return][/showif][hideif [_value]=3][return][{"0":"No state"}][/return][/hideif][/showif][showif [_name]=state][text]jsonResult=1[/text][showif [_value]=2][return][{"1":"New York"},{"2":"Another city"}][/return][/showif][hideif [_value]=2][return][{"0":"No city"}][/return][/hideif][/showif][hideif [jsonResult]=1][return][{"1":"Data 1"},{"2":"Data 2"},{"3":"Data 3"}][/return][/hideif][/function]However, as for what you are trying to get it to achieve depends on how closely you are modelling your site to this example. Does your clubs db have countries in it?Are you just trying to return JSON?in which case you will just need[search db=../admin/clubs.db&neLIGUEdata=FINDALL®IONsumm=t][[founditems]{[sku],'[region]'}[hideif [numfound]=[index]],[/hideif][/ founditems]][/search]Assuming that your SKU is an integer, this will build a JSON array for youIf you need help with the specifics, let me knowTCOn 26 Jan 2010, at 11:17, Lawrence wrote:> Hi,>> Can anyone help me with this.>> I have found a JQuery script that would save me a lot of time,(http://www.codeassembly.com/Simple-chained-combobox-plugin-for-jQuery/ > ) but it is linked to a PHP file.> I'm trying to create my own TPL file.> If there is a PHP Guru who could help me understand how to convert > the following code to some nice Webdna...> I have started with something looking like the following, but I'm > not sure I'm going the right direction.>> [search db=../admin/clubs.db&neLIGUEdata=FINDALL®IONsumm=t]> [arrayset name=region&dim=2,[numfound]]> [founditems]([SKU])=[region]> [/founditems][/arrayset]> [/search]>>>> Thanks in advance> Lawrence>> $array = array();> if ($_GET['_name'] == 'country')> {> if ( $_GET['_value'] == 3 )//usa> {> $array[] = array('1' => 'Montana');> $array[] = array('2' => 'New York');> $array[] = array('3' => 'Texas');> } else> {> $array[] = array('0' => 'No state');> }> } elseif ($_GET['_name'] == 'state')> {> if ( $_GET['_value'] == 2 )//New York> {> $array[] = array('1' => 'New York');> $array[] = array('2' => 'Another city');> } else> {> $array[] = array('0' => 'No city');> }> } else> {> $array[] = array('1' => 'Data 1');> $array[] = array('2' => 'Data 2');> $array[] = array('3' => 'Data 3');> }> echo json_encode( $array );> ?>
Associated Messages, from the most recent to the oldest:
Exactly translated to webdna, it goes a bit like this[function name=combobox][showif [_name]=country]
[text]jsonResult=1[/text][showif [_value]=3]
[return][{"1":"New York"},{"2":"Montana"},{"3":"Texas"}][/return][/showif][hideif [_value]=3]
[return][{"0":"No state"}][/return][/hideif][/showif][showif [_name]=state]
[text]jsonResult=1[/text][showif [_value]=2]
[return][{"1":"New York"},{"2":"Another city"}][/return][/showif][hideif [_value]=2]
[return][{"0":"No city"}][/return][/hideif][/showif][hideif [jsonResult]=1]
[return][{"1":"Data 1"},{"2":"Data 2"},{"3":"Data 3"}][/return][/hideif][/function]However, as for what you are trying to get it to achieve depends on how closely you are modelling your site to this example. Does your clubs db have countries in it?Are you just trying to return JSON?in which case you will just need[search db=../admin/clubs.db&neLIGUEdata=FINDALL®IONsumm=t][
[founditems]{[sku],'[region]'}[hideif [numfound]=[index]],[/hideif][/ founditems]][/search]Assuming that your SKU is an integer, this will build a JSON array for youIf you need help with the specifics, let me knowTCOn 26 Jan 2010, at 11:17, Lawrence wrote:> Hi,>> Can anyone help me with this.>> I have found a JQuery script that would save me a lot of time,(http://www.codeassembly.com/Simple-chained-combobox-plugin-for-jQuery/ > ) but it is linked to a PHP file.> I'm trying to create my own TPL file.> If there is a PHP Guru who could help me understand how to convert > the following code to some nice Webdna...> I have started with something looking like the following, but I'm > not sure I'm going the right direction.>> [search db=../admin/clubs.db&neLIGUEdata=FINDALL®IONsumm=t]> [arrayset name=region&dim=2,[numfound]]>
[founditems]([SKU])=[region]> [/founditems][/arrayset]> [/search]>>>> Thanks in advance> Lawrence>> $array = array();> if ($_GET['_name'] == 'country')> {> if ( $_GET['_value'] == 3 )//usa> {> $array[] = array('1' => 'Montana');> $array[] = array('2' => 'New York');> $array[] = array('3' => 'Texas');> } else> {> $array[] = array('0' => 'No state');> }> } elseif ($_GET['_name'] == 'state')> {> if ( $_GET['_value'] == 2 )//New York> {> $array[] = array('1' => 'New York');> $array[] = array('2' => 'Another city');> } else> {> $array[] = array('0' => 'No city');> }> } else> {> $array[] = array('1' => 'Data 1');> $array[] = array('2' => 'Data 2');> $array[] = array('3' => 'Data 3');> }> echo json_encode( $array );> ?>
Toby Cox
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:
Was it something I said??? (1998)
tax rate off by 1 cent (1997)
Search results templates (1996)
Summing fields (1997)
Round up prices (2000)
WebCat2 - [include] tags (1997)
Setting up WebCatalog with Retail Pro data (1996)
Database Fields (1997)
[WebDNA] opinions on [switch] [case]... (2009)
[CART] (1997)
Redirect (2003)
[WebDNA] Don't change [ipaddress] ... (2015)
Search returns all, not 20 (1997)
WebCat2b13 Mac plugin - [sendmail] and checkboxes (1997)
New Command prefs ... (1997)
Loop into field (1998)
Price written to db as scientific notation??? (1999)
[OT] Apple and 128bit SSL (2003)
take me off mailing list please (2001)
'page impression' techniques for banner ads (1999)