MyBB Community Forums

Full Version: List queries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

This is probably a stupid question, but I've recently made a page which receives data out of the database.

Now I want to list how many rows he loaded and list on the page

For example:

There are 100 users, my SQL command gets 58 users out of the database. Now I want to list the affected users. For example in an echo:

echo (".'$totalusers'. users listed")

I hope some can tell me command for thatToungue

Tankey
what is the code you have used for getting required results ? see count()
you can use a simple counter if you are not outputting html directly from your code. just increment a counter as you output the users and then update your output at the end with the counter value. saves a query that way
Hello,
I am using this code:

$memberlevel = $db->query("SELECT * FROM `".TABLE_PREFIX."usergroups` WHERE gid IN (8,9,10,12,13,14,15,20) ORDER BY gid ASC");
do you want to list only the number of users, or the number of users and then the list of those user?

also, how are you outputting the data? via mybb template system or direct echo?
$db->num_rows($memberlevel);

That will show the number of users selected.
(2011-12-09, 10:24 PM)Paul H. Wrote: [ -> ]
$db->num_rows($memberlevel);

That will show the number of users selected.

fine, take the easy way out Cool
(2011-12-09, 10:26 PM)pavemen Wrote: [ -> ]
(2011-12-09, 10:24 PM)Paul H. Wrote: [ -> ]
$db->num_rows($memberlevel);

That will show the number of users selected.

fine, take the easy way out Cool

Pretty much.
i have just had some weird behavior from the num_rows function. Sometimes it just does not return a value other than 0, when I can fetch_array and get output.... so I tend to work around that function if i can and dont forget about it working weird
How about adding "COUNT('field') AS num" to the query?
Pages: 1 2