php - Getting Combined Total Number Of MySQL Cells With Same Value: -
i'm working on forums project , struggle faced gathering total amount of mysql cells same value. point of total number of replies in specific topic in forums.
in specific circumstance, have table called post . in post , there cell called post_topic , same value topic_id table, topic (this attach replies directly topic). values in post_topic range 1 (being first topic), 2 (being second topic), etc.
what trying total amount of replies (post_topic) have same value, example if in post_topic there 40 cells value "7", how can mysql cherry pick 40 cells out of hundreds of others , echo through php?
here's i'm working with:
$sql = "select post_topic, topic_id post, topic"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result) echo '<button>' *** need value go here! *** '</button>;
i'm self taught, if write in code able understand it, problem haven't figured out how myself yet. i'm not great terms , whatnot , that's why couldn't find answer on google, sorry if frequent repeater. thank , help.
you can use following query find number of posts
select count(post_topic) post group post_topic
you can check specific post adding having
clause.
select count(post_topic) post group post_topic having post_topic = 7
i hope helps.
Comments
Post a Comment