Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:29:24+00:00 2026-05-25T19:29:24+00:00

I’m trying to display all comments made in certain posting page. All variable calls

  • 0

I’m trying to display all comments made in certain posting page. All variable calls work fine (including the function timeago) but it only shows the very first comment only.

$com_sql = "SELECT  comments.com_id,
                    comments.com_topic,
                    comments.com_user,
                    comments.com_content,
                    comments.com_date,
                    users.userid,
                    users.username,
                    users.usernombre,
                    COUNT(com_topic) AS com_top
            FROM comments
            LEFT JOIN users
            ON comments.com_user = users.userid
            WHERE com_topic = " . mysql_real_escape_string($_GET['id']) . "
            GROUP BY com_topic
            ORDER BY com_id DESC";

$com_result = mysql_query($com_sql);

if(!$com_result)
{echo 'The COMMENTS table could not be displayed.';}
else
{   if(mysql_num_rows($com_result) == 0){ echo 'No comments yet!';}
}

// Now I should show them one by one:
// Should $com_row be com_top??

while($com_row = mysql_fetch_assoc($com_result))
{ echo '<table width="100%" height="253" border="4">
<tr><td width="9%" rowspan="2" valign="top"><p>IMG</p>
<p>editar</p><p>&nbsp;</p><p>&nbsp;</p></td><td width="63%">';

$com_user = stripslashes($com_row['username']);
$com_usernombre = stripslashes($com_row['usernombre']);
echo $com_user;
echo $com_usernombre;

echo '</td><td width="4%" height="24"><div align="right"> <p>PM</p>
</div></td><td width="24%"><div align="right">';

$referencedate = strtotime($com_row['com_date']);
$result = timeago($referencedate); 
echo 'Ago';
echo $result ;

echo '</div></td></tr><tr><td colspan="3" valign="top">';

$com_content = stripslashes($com_row['com_content']);
echo $com_content;
echo '</td></tr>';
}
echo '</table>';

I am using the same template in other parts of my page and they work fine :-/
What am I doing wrong? Is the COUNT fine?? Am I using the while($com_row = mysql_fetch_assoc($com_result)) correctly??
Hope you can help me 🙂

THANKS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:29:25+00:00Added an answer on May 25, 2026 at 7:29 pm

    Your query will select one row for each distinct value of com_topic. This is due to the use of GROUP BY. If you omit the GROUP BY clause, then you should also omit the aggregate column COUNT(com_topic) as com_top.

    Otherwise, everything else looks ok.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.