每个帖子iD加载一个评论框(循环检索只一次)

每个帖子iD加载一个评论框(循环检索只一次)

问题描述:

I'm retrieving data from two MySQL tables, userUpdates & userComments. userUpdates loads correctly so does userComments.

Issue is while userUpdates prints many boxes (since it's inside a FOREACH loop) with it's correct information, userComments also prints the correct information but does not for all posts inside the loop.

All comments coming from userComments will only load for the first printed userUpdates box.

ILLUSTRATION :

The wrong way

Now this is how it should be,

ILLUSTRATION :

The correct way

My useless conclusion = It has nothing to do with userComments, but the userUpdates and how I'm position the data inside the .PHP file yet I'm unable to understand why it's not pulling the data correctly to all posts as it's showing for one specifically( always the last one posted/the latest).

[If it bothers anyone I can edit and post the code here]

This sits the query, for both userUpdates & userComments :

http://pastie.org/private/9exetjlvwgn4pfwgxzlktq#24

This sits the .PHP page, where I'm printing both the posts and including a include_once to load the userComments. :

http://pastie.org/private/jxrtobolbzsgaupsxt9mxq

I've been at it for 20 hours, didn't want to ask Stackoverflow so I could debbug and learn from my mistakes.. my brain is done least to say, any help or suggestions would be highly appreciated.

Is this not due to the fact that you are using include_once which doesn't then include the file on the subsequent loops. Try var_dumping the include_once statement. The first loop should return false and the others will return true if I'm correct. In that case just change it to a normal include function