Current location: Hot Scripts Forums » Programming Languages » PHP » Record Count


Record Count

Reply
  #1 (permalink)  
Old 04-12-04, 12:02 PM
D_tunisia D_tunisia is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Record Count

Hi want to do a post count for a news script I have written. All of my users have ID#'s which are referanced to posts in a table. Does anyone know how I do a count of all of the user's posts from my table?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 04-12-04, 12:20 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
i think it's something like this..

PHP Code:

   $query "SELECT count(*) FROM TABLE_NAME WHERE ID_USER='$USER_ID'";

   
$result mysql_query($query);
   
$query_data mysql_fetch_row($result);
   
$total_posts $query_data[0];
   
   echo 
$USER_ID ' posted ' $total_posts ' news articles'
see if that works (you have to mod it so it works for your script)
__________________
New beta project: GFX-PRO.ATH.CX
Description: GFX-PRO a great new project that anyone can and setup in less then a minute. [ More info ]
Website: http://gfx-pro.ath.cx
Status: Online
http://gfx-pro.ath.cx/sig.png
Reply With Quote
  #3 (permalink)  
Old 04-12-04, 12:27 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
to make it clearer using COUNT() is the solution .. as it said it counts records ..
and the rest is like Infinite_Hackers wrote ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #4 (permalink)  
Old 04-12-04, 01:25 PM
D_tunisia D_tunisia is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the help, that works great!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Multiple Images Kaikki ASP 6 01-31-04 05:57 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM
count images in a directory using javascript chuck JavaScript 5 12-05-03 01:20 PM
how do i add a record AND send an email in one step? nickleidecker ASP 2 10-14-03 07:12 PM
Post count, why? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 7 10-06-03 03:29 PM


All times are GMT -5. The time now is 10:26 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.