Re: [PHP-DB] count function?

2001-03-30 Thread DC

Ok i think i need to expand my help request... my fault

I have a db that uses ids for topics in a message board ie each topic has
messages of various numbers in them.

From my select a topic page i hope to put the number of messages in the
topic, so it visually looks like this sort of...

topic 1 bb (5 posts)
topic 2 ff (2 posts

and so on.

The only constant i can see in the tables is my posts table which specifies
the topic id number.

So i think i am asking how can i count the number of the same topic id
numbers and show that next to the relevant topic.

Thanks Again

Dave C
"Andrei Skorokhod" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if you just need the number

 SELECT COUNT(*) FROM table where 

 At 06:34 PM 3/30/2001 +0100, DC wrote:
 Hi All
 I cant quite work out how to count the number of rows in my mysql db that
 match a certain critieria and the show that number numericaly in my
pages.
 
 Checked books, php.net etc.
 
 Any help is appreciated
 
 Yours Dave C
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] count function?

2001-03-30 Thread Larry Rivera

I think you have to run multiple queries, ie run some loop after finding out
what topics you wil count from e==

run a select distinct to get the topics
run a while or for loop then run queries again like count(*) where
topic='$topic'

etc


then echo the result to each line


-Original Message-
From: DC [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 9:53 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] count function?


Ok i think i need to expand my help request... my fault

I have a db that uses ids for topics in a message board ie each topic has
messages of various numbers in them.

From my select a topic page i hope to put the number of messages in the
topic, so it visually looks like this sort of...

topic 1 bb (5 posts)
topic 2 ff (2 posts

and so on.

The only constant i can see in the tables is my posts table which specifies
the topic id number.

So i think i am asking how can i count the number of the same topic id
numbers and show that next to the relevant topic.

Thanks Again

Dave C
"Andrei Skorokhod" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if you just need the number

 SELECT COUNT(*) FROM table where 

 At 06:34 PM 3/30/2001 +0100, DC wrote:
 Hi All
 I cant quite work out how to count the number of rows in my mysql db that
 match a certain critieria and the show that number numericaly in my
pages.
 
 Checked books, php.net etc.
 
 Any help is appreciated
 
 Yours Dave C
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] count function?

2001-03-30 Thread DC

Ok i will get the books out and see if i can construct something.

Thanks for the tip...
 Dave C
""Larry Rivera"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I think you have to run multiple queries, ie run some loop after finding
out
 what topics you wil count from e==

 run a select distinct to get the topics
 run a while or for loop then run queries again like count(*) where
 topic='$topic'

 etc


 then echo the result to each line


 -Original Message-
 From: DC [mailto:[EMAIL PROTECTED]]
 Sent: Friday, March 30, 2001 9:53 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] count function?


 Ok i think i need to expand my help request... my fault

 I have a db that uses ids for topics in a message board ie each topic has
 messages of various numbers in them.

 From my select a topic page i hope to put the number of messages in the
 topic, so it visually looks like this sort of...

 topic 1 bb (5 posts)
 topic 2 ff (2 posts

 and so on.

 The only constant i can see in the tables is my posts table which
specifies
 the topic id number.

 So i think i am asking how can i count the number of the same topic id
 numbers and show that next to the relevant topic.

 Thanks Again

 Dave C
 "Andrei Skorokhod" [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  if you just need the number
 
  SELECT COUNT(*) FROM table where 
 
  At 06:34 PM 3/30/2001 +0100, DC wrote:
  Hi All
  I cant quite work out how to count the number of rows in my mysql db
that
  match a certain critieria and the show that number numericaly in my
 pages.
  
  Checked books, php.net etc.
  
  Any help is appreciated
  
  Yours Dave C
  
  
  
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail:
[EMAIL PROTECTED]
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] count function?

2001-03-30 Thread Brian S. Dunworth

At 10:06 AM 3/30/01 -0800, Larry Rivera wrote:
I think you have to run multiple queries, ie run some loop after finding out
what topics you wil count from e==

run a select distinct to get the topics
run a while or for loop then run queries again like count(*) where
topic='$topic'

   Better yet (and less db-intensive), run a

SELECT TOPIC,COUNT(*) FROM table_name
   WHERE condition
   GROUP BY TOPIC
   ORDER BY COUNT(*);

That'll return:

  TOPICCOUNT(*)
   
  Topic A 8
  Topic B 3
  Topic C 1
  Topic D 0
  Topic E 0


  -
Brian S. Dunworth
Sr. Software Development Engineer
Oracle Database Administrator
The Printing House, Ltd.

(850) 875-1500  x225
[EMAIL PROTECTED]
  -


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] count function?

2001-03-30 Thread DC

Cheers Brian
Thats sounds more like i am looking for
Although i have put the other code examples offered for this prob in my code
folder for later cause you never now when you'll need them.

Cheers

Dave C
""Brian S. Dunworth"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 At 10:06 AM 3/30/01 -0800, Larry Rivera wrote:
 I think you have to run multiple queries, ie run some loop after finding
out
 what topics you wil count from e==
 
 run a select distinct to get the topics
 run a while or for loop then run queries again like count(*) where
 topic='$topic'

Better yet (and less db-intensive), run a

 SELECT TOPIC,COUNT(*) FROM table_name
WHERE condition
GROUP BY TOPIC
ORDER BY COUNT(*);

 That'll return:

   TOPICCOUNT(*)
    
   Topic A 8
   Topic B 3
   Topic C 1
   Topic D 0
   Topic E 0


   -
 Brian S. Dunworth
 Sr. Software Development Engineer
 Oracle Database Administrator
 The Printing House, Ltd.

 (850) 875-1500  x225
 [EMAIL PROTECTED]
   -


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] count function?

2001-03-30 Thread Phil Jackson

What is retrieved if you do a Select Count(*) from myDb where
condition = parameters?

Seems your result set should contain this value...
Phil J.


DC wrote:

 Hi All
 I cant quite work out how to count the number of rows in my mysql db that
 match a certain critieria and the show that number numericaly in my pages.

 Checked books, php.net etc.

 Any help is appreciated

 Yours Dave C

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] count function?

2001-03-30 Thread Andrei Skorokhod

if you just need the number

SELECT COUNT(*) FROM table where 

At 06:34 PM 3/30/2001 +0100, DC wrote:
Hi All
I cant quite work out how to count the number of rows in my mysql db that
match a certain critieria and the show that number numericaly in my pages.

Checked books, php.net etc.

Any help is appreciated

Yours Dave C



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]