473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

threaded comments

so i\'ve been trying to build a threaded comments section on my website, with little to no luck trying to figure out how to loop through 2 while loops and load my comments. i\'ve read a lot of different code snippets and comments about this, and seem to get further lost.. here is what im attempting, mysql database looks like this
id
profile_id
parent
type " 'a', 'b' "
comment
datetime
so far ive tried doing it with one query and one loop, and 2 queries and 2 loops, and i only ever get errors or just one parent and one child.... and i have many parents and many children, but children are only one deep... i dont necessarily need the answeres or someone to do this for me, but maybe someone know a good easy to understand tutorial i can go through to help me unserstand... thanks
Dec 1 '11 #1

✓ answered by Rabbit

I suppose you would do something like this
Expand|Select|Wrap|Line Numbers
  1. sql = "select parents from comments"
  2.  
  3. for each row in sql
  4.    output sql.comment
  5.    sql2 = "select children from comments where parent = " + sql.parent
  6.  
  7.    for each row in sql2
  8.       output sql2.comment
  9.    next
  10. next

7 2412
Rabbit
12,516 Expert Mod 8TB
Can you post an example of what you mean by threaded comments?
Dec 1 '11 #2
I'm not on my computer right now so hope this can help clarify. If not I can try posting some code.
By threaded comments I'm talking about comments people leave for others. I hate to say it. But. Like facebook. Or better yet like YouTube. Structured like this
Parent
Child
Child
Parent
Parent
Child
Dec 2 '11 #3
Rabbit
12,516 Expert Mod 8TB
Can't a child also be a parent?
Dec 2 '11 #4
In some instances they can be. But for what I'm tryingto do I don't want children to be parents
Dec 2 '11 #5
Rabbit
12,516 Expert Mod 8TB
I suppose you would do something like this
Expand|Select|Wrap|Line Numbers
  1. sql = "select parents from comments"
  2.  
  3. for each row in sql
  4.    output sql.comment
  5.    sql2 = "select children from comments where parent = " + sql.parent
  6.  
  7.    for each row in sql2
  8.       output sql2.comment
  9.    next
  10. next
Dec 2 '11 #6
thats it... thank you so much. i tweaked it a little but thats it, and its working great... :D
Dec 3 '11 #7
omerbutt
638 512MB
you must select the right answer to the question if you think he has provided you with the solution , so that this could be helpful to any one else who comes here googling.
regards,
Omer Aslam
Dec 3 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ensnare | last post by:
I'm attempting to create a threaded comment system involving PHP / MySQL. Currently, I have a table called comments which looks like: Table Comments: (comment_id, comment_root_id,...
0
by: Stuart Norris | last post by:
Dear Group, I am attempting to write a "splash" and "status" Form using a second thread. I wish to use this Form to display status information to the user when I do CPU intensive work in my...
0
by: Stephen Olmsted | last post by:
I'm going to be writing multi-threaded interfaces that run in the background as Windows Services. Are there any good books that people can recommend that would be good resources for such a project?...
6
by: ben | last post by:
I am needing a web service to be single threaded. Is this possible? Any ideas would be helpful
36
by: lovecreatesbeauty | last post by:
Any comments are welcome for following the two sequential search C functions of both integer and string versions. Though they are simple, please do not laugh at it :) Could you give your great...
0
by: apexi.200sx | last post by:
Just wondering if anyone could give me advice on handling potential error conditions in python, it seems that exceptions are used alot more for this stuff than in other languages. I have...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
3
by: Jamie Risk | last post by:
I'm attempting to improve some serially executing code (that uses the SerialPort class) bogging Windows down when it runs. To do the 'antibogging' I'm following the example from MSDN...
0
by: William Gill | last post by:
It may be that I'm just tired and my brain isn't working, but can anyone point me to some simple examples of how to create a "threaded message page" for visitor comments. The volume is too small...
14
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.