Jump to content

returning a count from a table but not including where one field is the same


Recommended Posts

Slight query I have a database that has my online users in it how can i add something to it where the 'username' field is thesame for example

 

$getusers='';
$getusers="SELECT * FROM `tblonline` WHERE `usertype`='user'";

 

I need something to filter out if the user has opened two browsers and is logged in for example 'username'='john' might appear twice in the table but I only want to count it once with the num_rows query

you can group your results by username, then count them in the way you prefer

 


$getusers="SELECT * FROM `tblonline` WHERE `usertype`='user' GROUP BY `username` ";

 

it will give you one result per-user logged

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.