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 you If you need help with the specifics, let me know TC On 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:

    
  1. RE: [WebDNA] PHP Array translated to Webdna ("Olin Lagon" 2010)
  2. Re: [WebDNA] PHP Array translated to Webdna (Toby Cox 2010)
  3. [WebDNA] PHP Array translated to Webdna (Lawrence 2010)
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 you If you need help with the specifics, let me know TC On 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:

HELP WITH DATES (1997) emailer (1998) WebCat2 beta 11 - new prefs ... (1997) Migrating to NT (1997) taxTotal, grandTotal (1997) SMTP Mail Server (2003) Funny Math (2000) Where is the bug fix info for 4.0.1? (2000) I have troubles to send message out (1998) Webcat table size. (2001) easiest way to check for a non-alphanumeric character? (2000) WebCat2b15MacPlugin - showing [math] (1997) Duplicate Cart ID (2001) WebCat2b12 - nesting [tags] (1997) WebCatalog-NT?'s (1996) Re2: Calculating multiple shipping... (1997) [no_cache]?! (2000) breaking words (1997) 2.1b3 --> way slow (1997) WebMerchant 1.6 and SHTML (1997)