Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-31-2009, 07:53 AM   PM User | #1
Ndogg
Regular Coder

 
Join Date: Jun 2009
Posts: 272
Thanks: 76
Thanked 2 Times in 2 Posts
Ndogg can only hope to improve
Count

I want to count how many banners a user has posted:

PHP Code:
$query mysql_query('SELECT author, COUNT(author) FROM graphic GROUP BY author') or die(mysql_error()); 
How do I make it so it counts the rows(author) and to get the username to select its $username.
Ndogg is offline   Reply With Quote
Old 07-31-2009, 08:02 AM   PM User | #2
Zangeel
Regular Coder

 
Zangeel's Avatar
 
Join Date: Oct 2007
Location: public_html/
Posts: 638
Thanks: 17
Thanked 79 Times in 79 Posts
Zangeel will become famous soon enough
PHP Code:
 $query mysql_query('SELECT COUNT(author) FROM graphic GROUP BY author') or die(mysql_error()); 
__________________
PHP Code:
$aString is_string((string)array()) ? true false// true :D 
[/CENTER]
Zangeel is offline   Reply With Quote
Old 07-31-2009, 08:11 AM   PM User | #3
Ndogg
Regular Coder

 
Join Date: Jun 2009
Posts: 272
Thanks: 76
Thanked 2 Times in 2 Posts
Ndogg can only hope to improve
same thing happens
Ndogg is offline   Reply With Quote
Old 07-31-2009, 08:32 AM   PM User | #4
Zangeel
Regular Coder

 
Zangeel's Avatar
 
Join Date: Oct 2007
Location: public_html/
Posts: 638
Thanks: 17
Thanked 79 Times in 79 Posts
Zangeel will become famous soon enough
PHP Code:
$q mysql_query("SELECT count(author) FROM `graphic` WHERE `author` = 'username goes here'");

$row mysql_fetch_assoc($q);

echo 
'Username posted' $row['count(author)'] . ' banners'
__________________
PHP Code:
$aString is_string((string)array()) ? true false// true :D 
[/CENTER]
Zangeel is offline   Reply With Quote
Users who have thanked Zangeel for this post:
Ndogg (07-31-2009)
Old 07-31-2009, 09:05 AM   PM User | #5
Ndogg
Regular Coder

 
Join Date: Jun 2009
Posts: 272
Thanks: 76
Thanked 2 Times in 2 Posts
Ndogg can only hope to improve
Its not displaying anything now?
Ndogg is offline   Reply With Quote
Old 07-31-2009, 09:12 AM   PM User | #6
Ndogg
Regular Coder

 
Join Date: Jun 2009
Posts: 272
Thanks: 76
Thanked 2 Times in 2 Posts
Ndogg can only hope to improve
Nevermind, fixed it, thanks!
Ndogg is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:56 AM.


Advertisement
Log in to turn off these ads.