Re: Need to count number of rows per id! :(

From: Date: Sat, 03 Feb 2001 03:37:10 +0000
Subject: Re: Need to count number of rows per id! :(
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37930@lists.php.net to get a copy of this message
Are you looking for select topicID, count(*) from $secondtable group by topicID? This will give you a count of each distinct topicID in $secondtable. Julian -- Julian Wood Multimedia Developer University of Calgary on 2/2/01 6:15 PM, Sandeep Hundal at sandeep_wde@yahoo.com wrote: > > Hey guys, > > I need an answer to a problem I've been trying to work on for days :( > > I made a message board, which has a front page which lists Topic > name, topic started by, and what date. All this info, and the topic > message is stored in one mysql table. when you click on any of the > topics, it leads to a page which lists all replies to that topic by > topic_id. > > Now what I want to do is have a listen on the first index page, the > number of replies for that particular topic. I know I need something > like select id from $secondtable where topicid=$topicid, and then use > mysql_num_rows, but I can't figure out how to integrate the first set > of results from table 1 with the query on table 2. > > This is the query on the front page on the main table : > $query = "SELECT topicid, icon, name, topic, datestamp FROM > $maintable ORDER by datestamp DESC LIMIT 40 "; > $result = mysql_query($query); > > TIA! > > Sandeep > > __________________________________________________ > Get personalized email addresses from Yahoo! Mail - only $35 > a year! http://personal.mail.yahoo.com/

« previous php.general (#37930) next »