Skip to main content
Inspiring
January 31, 2009
Question

Hi Guys, a Recusion is Cutting me Off

  • January 31, 2009
  • 5 replies
  • 2726 views
I have a PHP code which uses recursion to get categories and subcategories.

I am trying to convert it with coldfusion but getting into trouble:

here is the code:

$result = mysql_query("select title,parentid from cat where cid=$catid");
list($title,$parentid)=mysql_fetch_row($result);
$title=getparentlink($parentid,$title);
This topic has been closed for replies.

5 replies

Inspiring
February 3, 2009
What is the code that generates those displays?
Inspiring
February 2, 2009
A single query with query of queries to get the counts would be much more efficient than using queries inside a query.

As far as the breadcrumb goes, what have you accomplished so far, and what is it you want to display?
Inspiring
February 3, 2009
I have worked such as:

Home: CategoryName

and if i select subcategory it replace the above as:

Home: Subcatname

but i want it to appear it as:

Home: categoryName: subcatName

Inspiring
February 1, 2009
You are running way too many queries. You only need one as far as I can see.

select yourfields
from cat c join category ca on c.catid = ca.catid
join table t on ca.catid = t.catid
order by categoryname, subcategoryname

Then use the group attibute of cfoutput to organize your display.
Inspiring
January 31, 2009
> I have a PHP code which uses recursion to get categories and subcategories.
>
> I am trying to convert it with coldfusion but getting into trouble:
>

Could you possibly post the code you're having trouble with, and explain
what the trouble actually is?

--
Adam
Inspiring
February 1, 2009
Hi Guys, Here is the Code, I am trying to Do:

i get query results as: select * from cat where parentid = 0

now i use this query as:

<cfoutput query="results">
<cfquery datasource="#request.dsn#" name="a">
select catID, category from
categories
where
parentid = <cfqueryparam cfsqltype="cf_sql_numeric" value="#Trim(results.catID)#">
</cfquery>
<td height="30" valign="middle"><strong><a href="index.cfm?catID=#URLEncodedFormat(catID)#">#category#</a></strong><br>
<cfloop query="a">
<cfquery datasource="#request.dsn#" name="showanother">
select * from table
where catID=<cfqueryparam cfsqltype="cf_sql_numeric" value="#Trim(a.catID)#">
</cfquery>
<a href="index.cfm?catID=#URLEncodedFormat(catID)#">#Category#</a>
</cfloop>
</cfoutptut>

Bur it is appearing like:

Home: CategoryName

and if i select another category it is appearing as:

Home: SubCategoryName

But I want Something like this:

Home: CategoryName: SubCategoryName

Hope u understand what i am trying to do here:

Regards
Inspiring
January 31, 2009
The first line runs a query.
The second converts the query to a list.
The third one runs a function that appears to run a query for the parentid.

If this is recursion, this code should be in a loop.