Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Manipulation?

Status
Not open for further replies.

joelxez

Programmer
Apr 18, 2002
67
PH
Hi Experts,

Anyone who can give some tips on how to create an output below. I have a table name table1 which has 3 columns IDNum, Child, name.
If Child is EQ to IDnum then name will display just like the main topic, if Child is NOT EQ to IDNum then the name will display just like a sub topic of the main.

-----------------------------------------------------------
Table: table1
IDNum Child name

1 1 Pr1
2 1 Pr1-1
3 3 Pr2
4 3 Pr2-1
5 2 Pr1-1-1
6 6 Pr3
7 7 Pr4
8 1 Pr1-2
9 6 Pr3-1

-----------------------------------------------------------
Output:

Pr1
Pr1-1
Pr1-1-1
Pr1-2
Pr2
Pr3
Pr3-1
Pr4



John,
 
Your example is a little to abstracted for my dull brain at this hour of the morning ;-)

Is this script trying to store and retrieve catalogue level information in a flat file?

In other words, are you trying to locate products within categories and subcategories and store all that data in one table?

(I now think MY question is more confusing than YOURS! lol)

Mike
 
Hi Mike,

I,m just trying to retrieve data from one table and display it in a page.

I have a code but it does'nt work with multiple subcategories/subtopic, it works only with one subcategories/subtopic.
-----------------------------------------------------------

Heres the code....

<cfquery name="qtask" datasource="promanager">
SELECT min(taskID) as minID, max(taskID) as maxID, max(taskparent) as maxparent, taskparent, taskname
FROM tbtask Group BY taskparent
</cfquery>
<CFLOOP INDEX="prent" FROM="#qtask.minID#" TO="#qtask.maxID#">
<cfquery name="gettaskID" datasource="promanager">
select taskname from tbtask where taskID=#prent# and taskID=taskparent
order by taskID
</cfquery>
<!---Record Found--->
<cfif #gettaskID.recordcount# gte 1>
<cfoutput>#prent#</cfoutput>
<cfoutput query="gettaskID">#gettaskID.taskname#</cfoutput><br>

<cfquery name="getidchild" datasource="promanager">
select taskname from tbtask where taskparent=#prent#
and taskID != taskparent
</cfquery>

<cfif #getidchild.recordcount# gte 1>
<blockquote>
<cfoutput query="getidchild">#taskname#<br></cfoutput>
</blockquote>
<cfloop from="#qtask.minID#" to="#qtask.maxparent#" index="subparent">
<cfquery name="getidSubchild" datasource="promanager">
select taskname from tbtask where taskparent=#subparent#
GROUP By taskparent
</cfquery>
<cfif #getidSubchild.recordcount# gte 1>
<blockquote>
<cfoutput query="getidSubchild">#taskname#<br></cfoutput>
</blockquote>
<cfelse>
<cfoutput>>norec</cfoutput>

</cfif>
</cfloop>
</cfif>
</cfif>

</CFLOOP>


Joel,
 
Look up category trees, this has been done many a time before, no point in reinventing the wheel.


ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
hi webmigit,

i'm getting an error "Cannot find CFML template for custom tag MyMakeTree". looks like my CFML does'nt support the "MyMakeTree" tag. What should i do!

Joel
 
Have you downloaded the tag? If so, you need to make sure it's in the proper place for CF to get to it. Either put it in your custom tags directory or in the same folder with the CF files that are calling it.



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
I know that cf supports mymaketree, its been years but I've used it and since written my own versions..

Try Ecobb's suggestion.. the easiest way to test of course is to just put it in the same folder as the calling page..

So mymaketree.cfm (make sure the file is called that, exactly) and callingpage.cfm (or whatever the name of your calling page is) are in the same folder.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
hi webmigit,

can u just send me a sample?

jllano@mozcom.com

joel
 
Example of what? A category custom tag? Mymaketree is the example...

Its probably one of the best documented tags I've ever seen.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top