Old 09-22-2005   #1 (permalink)
Registered User
 
Space Cowboy's Avatar
 
Join Date: May 2005
Location: England (South)
Posts: 40

Counting in SQL

Im trying to count the number of members registered and the number of members loged in using php and display them in a variable, I dont have a clue where to start, can some one give me a shuve in the right direction!
__________________
Space Cowboy

Thanks for all the help here guys!
Space Cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-22-2005   #2 (permalink)
Sheep Worrier
 
Man1c M0g's Avatar
 
Join Date: Sep 2003
Location: Portsmouth, UK.
Posts: 4,073
Blog Entries: 14

Send a message via ICQ to Man1c M0g Send a message via MSN to Man1c M0g Send a message via Skype™ to Man1c M0g
Crikey! Well, that depends massively on what kind of membership system you are running! If you just want to count how many users are online using PHP, then you may want to pop over to http://www.devarticles.com/c/a/PHP/T...nline-With-PHP
__________________
Man1c M0g is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-23-2005   #3 (permalink)
Registered User
 
Space Cowboy's Avatar
 
Join Date: May 2005
Location: England (South)
Posts: 40

Well actualy i have a var called loged in that is 1 when a user is loged in and 0 when they are loged out! Can i count the number of 1's in the loged in collum of my sql databaes!
__________________
Space Cowboy

Thanks for all the help here guys!
Space Cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-23-2005   #4 (permalink)
Sheep Worrier
 
Man1c M0g's Avatar
 
Join Date: Sep 2003
Location: Portsmouth, UK.
Posts: 4,073
Blog Entries: 14

Send a message via ICQ to Man1c M0g Send a message via MSN to Man1c M0g Send a message via Skype™ to Man1c M0g
Sounds like I can help here! I use a custom function to do this sort of thing. Simply add this to your code somewhere:
PHP Code:
function getRows($table$where)
{
  global 
$t;

  
$sql "SELECT * FROM " $table " WHERE " $where;
  
sqlTrace("getRows"$sql);
  
$result mysql_query($sql);
  
$countOfRows mysql_num_rows($result);

  
$ii 0;
  
$row = array($countOfRows);

  if (
$countOfRows 0)
  {
    while (
$row mysql_fetch_array($result))
    {
      
$rows[$ii++] = $row;
    }
  }

  return 
$rows;

And then when you want to use the function, use code similar to this....
PHP Code:
$countOfOnline getNumRows("online_table""online_row > 0");
echo 
$countOfOnline
__________________
Man1c M0g is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-24-2005   #5 (permalink)
Invicible Snake
 
ParaSnake's Avatar
 
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668

Send a message via MSN to ParaSnake Send a message via Yahoo to ParaSnake
mysql_num_rows is all you have to know
check it here
http://www.php.net/manual/en/functio...l-num-rows.php
__________________
ParaSnake is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-25-2005   #6 (permalink)
Registered User
 
Space Cowboy's Avatar
 
Join Date: May 2005
Location: England (South)
Posts: 40

Thanks guys ill check both scripts out thanks again!
__________________
Space Cowboy

Thanks for all the help here guys!
Space Cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 09-29-2005   #7 (permalink)
Local Biorust Beast
 
Order's Avatar
 
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253

Send a message via AIM to Order Send a message via MSN to Order Send a message via Yahoo to Order
Actually, this one query answers it all:

SELECT COUNT(*) WHERE logged_in = 1

Booya.
__________________
Order is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

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


All times are GMT +1. The time now is 10:30 AM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT