0

Whats Wrong with my code its Returning 0

            $query = "SELECT cid, COUNT(cid) FROM topic_reply WHERE cid='$forum_id'";    
        $result = mysql_query($query) or die(mysql_error());    
        while($row = mysql_fetch_array($result)){
            echo "There are ". $row['COUNT(cid)'] ." ". $row['cid'] ." items.";
            echo "<br />";
        }

I try all possible codes to display the results by its returng 0.. but if i remove the WHERE filter its returns all rows what happened? hehe

1 Answer 1

1

I'm not sure what you are trying to accomplish but I think it might be a count of a particular cid:

$query = "SELECT cid, COUNT(cid) FROM topic_reply WHERE cid='$forum_id' GROUP BY cid";
Sign up to request clarification or add additional context in comments.

2 Comments

$forum=mysql_query("SELECT * FROM forum WHERE pid='$cat_id'"); while($forumrow = mysql_fetch_array($forum)) { // code here $threadcount=mysql_query("SELECT * FROM topics WHERE parent='$forum_id'"); $thread_count_rows = mysql_num_rows($threadcount); while($threadrow = mysql_fetch_array($threadcount)) { $parent_id = $threadrow['id']; } // some more code here Continue Below
$query = "SELECT cid, COUNT(cid) FROM topic_reply WHERE cid='$forum_id' GROUP BY cid"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $temp1 = $row['COUNT(cid)']; if($temp1==1) { echo '<img StarImage_1.png>'; } elseif($temp1>=10) { echo '<img StarImage_2.png>'; } // and so on} }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.