|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Help with 2D arrays
I haven't long been working with arrays, and I'm wondering just how to accomplish the following....First off, here's what I have so far (using fuseQ)...
in act_pricelists.cfm <cfscript> commonplist = ArrayNew( 2 ); commonplist[1][1] = 'Brother Dealer'; commonplist[1][2] = 'http://www.brother.com/'; commonplist[2][1] = 'Brother Solutions'; commonplist[2][2] = 'http://www.brothersolutions.com/'; </cfscript> This outputs fine in dsp_pricelists.cfm <cfoutput> <cfloop from = "1" to="#ArrayLen( commonplist )#" index="aRow" > <cfloop from = "1" to="#ArrayLen( commonplist[1] )#" index="aCol" > #commonplist[aRow][aCol]# </cfloop> <br /> </cfloop> </cfoutput> and this is all fine, with the output looking something like... Brother Dealer http://www.brother.com/ Brother Solutions http://www.brothersolutions.com/ But what I want is the 2nd element of the array to be used as the url. E.G. in dsp_pricelists.cfm I would like to see <a href="http://www.brother.com/">Brother Dealer</a> <a href="http://www.brothersolutions.com/">Brother Solutions</a> or even Brother Dealer <a href="http://www.brother.com/">URL</a> Brother Solutions <a href="http://www.brothersolutions.com/">URL</a> Is this possible?? ----------------------------------------------- All help appreciated TIA MarkH |
|
#2
|
|||
|
|||
|
I'm sure it is possible using the arrays. But I think that using a structure would make this so much easier?
Code:
<cfscript> commonplist = ArrayNew( 1 ); commonplist[1] = structNew(); commonplist[1].name = 'Brother Dealer'; commonplist[1].url = 'http://www.brother.com/'; commonplist[2] = structNew(); commonplist[2].name = 'Brother Solutions'; commonplist[2].url = 'http://www.brothersolutions.com/'; </cfscript> <cfoutput> <cfloop from = "1" to="#ArrayLen( commonplist )#" index="thisRow" > <a href="#commonplist[thisRow].url#">#commonplist[thisRow].name#</a> </cfloop> </cfoutput>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I tinkered with the idea of structures for a start but since I'd just completed a tutorial on arrays I guess I had been blinded to the requirements of job...
thanks once again Kiteless! |
|
#4
|
|||
|
|||
|
how to save query values into a session
How can i move the query results into an array into sessions, so that i want to those on the later page.
|
|
#5
|
|||
|
|||
|
You can simply do:
<cfquery name="session.myQuery"> ... </cfquery> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Help with 2D arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|