I am building a small social network for my department.

I have the homepage as a place where you can make comments and your friends can comment on it.

I have 4 tables ...allposts_tb, friendship_tb,response_tb and signup_tb..

The allposts_tb collect the updates and post made by people it has the following columns (all_id(PK),name,comment,time)

The friendship_tb as the columns (friend_id(Pk),myname,newfriend,status)

The response_tb as columns(id(Pk),name,response,all_id(Fk),time)

The signup_tb as columns (signup_id,lastname,firstname,email,password,country,profilepicture)

I can display comments made by people easily using the sql query below

SELECT allposts_tb.all_id,allposts_tb.name,allposts_tb.comment, allposts_tb.time,
friendship_tb.myname,friendship_tb.newfriend,signup_tb.firstname,
signup_tb.lastname,signup_tb.email,signup_tb.profilepicture,
allposts_tb.expand
FROM allposts_tb,friendship_tb,signup_tb
WHERE allposts_tb.name = friendship_tb.newfriend
and friendship_tb.myname=colname and
allposts_tb.name=signup_tb.email
ORDER BY allposts_tb.all_id DESC

The colname is a session variable having value "$_SESSION['MM_Username']"

Well am having problems displaying responses made by people on a particular comment right below the comment...just like replicating facebook's page.Immediately you say something,it should be displayed right below the comment... I know am meant to use a sub query or UNION ALL right inside the query i gave you guys..have read a lot of web pages but cant get it to work...please help me...

i think you need loop in loop
first run that your query

then in that loop run query in second loop
from response_tb where all_id =first loop all_id

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.