Jump to content

Row Count


SkyRanger

Recommended Posts

I am trying to count rows where there is multiple entries.

 

userlevels: (column name)

2

3

4

 

I can get them to post separate

 

What I need to do is do a row count with 2 of the number 3 and 4

 

example:

 

userlevels:

 

2 - 1 Entry

3 - 2 entries

4 - 3 entries

 

if ($resultt = $mysqli->query("SELECT userlevel FROM users where userlevel='3' and userlevel='4' ")) {

   /* determine number of rows result set */
   $row_cntt = $resultt->num_rows;

   printf("%d", $row_cntt);

   /* close result set */
   $resultt->close();
}

 

I got it so:

 

Level 2 : 1 User

Other: 0 Users but as stated there are 2 for 3 and 3 for 4

Link to comment
Share on other sites

Thank Jessica,

 

ok Tried this and still an output of 0

 

if ($resultt = $mysqli->query("SELECT userlevel, count(*) FROM users where userlevel='3' and userlevel='4' group by userlevel")) {

/* determine number of rows result set */
$row_cntt = $resultt->num_rows;

printf("%d", $row_cntt);

/* close result set */
$resultt->close();
}

Edited by SkyRanger
Link to comment
Share on other sites

A user level can't be both equal to 3 and equal to 4. There is no such number. Furthermore, if you want the output you said in your first post, you don't want the number of rows returned, you want the actual rows.

Edited by Jessica
Link to comment
Share on other sites

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.