Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
joerivl #1
Function using same function
Hi
I would like to make a function that can refer to itself if a certain action
occurs.
In this case, a function that loops through a table, gets the ID and performs
the same function to get the children
output must be like this
home
categ. A
categ. A1
categ A1.1
categ. A2
categ. B
categ B1
My attached code shows only the first line.
what I'm I doing wrong?
any suggestions are welcome...
Tnx
Table categories:
[ page_id | page_title | parentid ]
| 1 | home | 0 |
| 2 | categ. A | 0 |
| 3 | categ. B | 0 |
| 4 | categ. A1 | 2 |
| 5 | categ. A2 | 2 |
| 6 | categ. B1 | 3 |
| 7 | categ. A1.1| 4 |
<cfscript>
function DisplayCategories(parentid) {
SQLString = "SELECT page_id, page_title FROM categories WHERE parentid=" &
parentid;
DATASOURCE = "website_one";
getcategories=getquery(SQLString: SQLString, DATASOURCE: DATASOURCE);
if (getcategories.RecordCount GT 0)
{
for(currRow=1; currRow LTE getcategories.RecordCount; currRow=currRow+1)
{
WriteOutput(sublevelmarker&getcategories.page_id[CurrRow]&':');
WriteOutput(sublevelmarker&getcategories.page_titl e[CurrRow]&'<br>');
DisplayCategories(getcategories.page_id[CurrRow]);
};
};
};
DisplayCategories(0);
</cfscript>
joerivl Guest
-
[PHP-DEV] named function arguments (was: Proposal: Dangling comma in function
Christian Schneider wrote: Named parameters - i think is very good idea. I know i would use them. I'm really not sure about the correct... -
#25866 [Bgs]: Using error_reporting() function don't change output of phpinfo() function
ID: 25866 Updated by: sniper@php.net Reported By: sfournier at dmsolutions dot ca Status: Bogus Bug Type: ... -
note 33714 added to function.register-tick-function
please can anyone help me to discover if this function can be used to make a chat ---- Manual Page --... -
note 33575 added to function.register-shutdown-function
If your script exceeds the maximum execution time, and terminates thusly: Fatal error: Maximum execution time of 20 seconds exceeded in - on line... -
note 33132 deleted from function.register-shutdown-function by sniper
Note Submitter: markus@malkusch.de ---- I can't agree with nick at nickjoyce dot com. I use php 4.2.3 on linux and my shutdown function is... -
Adam Cameron #2
Re: Function using same function
When writing functions, you generally want to declare all variables as
local, especially when writing recusrive code such as you are.
<cfset var foo = "bar">
--
Adam
Adam Cameron Guest
-
DaveF67 #3
Re: Function using same function
in a component have two functions:
<CFFunction name="doLoop" output=yes>
DaveF67 Guest
-
joerivl #4
Re: Function using same function
I have seperated the query as suggested and everything seems to work now...
Thanks!
joerivl Guest



Reply With Quote

