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:
WebCat2 - [format thousands] (1997)
unable to launch acgi in WebCat (1997)
Email Set-Up? (1997)
[WebDNA] SCOPE:, ---- was:--- Date: header on emails - timezone problem perhaps (emai)
Superfilous Characters (1998)
WebDelivery downloads alias, not original ? (1997)
No Answer on Web Merchant Problem? (2001)
When do we get to request new features? (1999)
Draft Manual, Tutorial, and more (1997)
Showif -what am I missing??? (1999)
Two options to consider (2008)
[lowercase] and [mixedcase] (1998)
(2004)
PIXO support (1997)
Suffix Mapping (1997)
RE: Formulas.db + Users.db (1997)
WebCat for Unix?? (1997)
Separate SSL Server (1997)
2.0 Beta (1997)
Emailer help....! (1997)