Jump to content

Count in order


avatar.alex

Recommended Posts

ok i need the little code to could the users in order i have the

the data already being displayed from the database but I want it in order on how the user joins like look how it goes

1

14

7

8...

 

I want it to go

1

2

7

8

9

10....

and keep in that order I displayed the database like

 

$query="SELECT * FROM bl_admin ";

 

 

 

1 	-username-
14 	-username- [email protected]
7 	- username- [email protected]
8 	-username- [email protected]
9 	-username- [email protected]
10 	-username- [email protected]
11 	-username- [email protected]
12 	-username- [email protected]
13 	-username- [email protected]

 

also I want to count the users in the database like

 

You have XX registered users.

Link to comment
https://forums.phpfreaks.com/topic/49884-count-in-order/
Share on other sites

Let's assume your table looks like:

id int autoincrement,

username varchar,

email varchar

 

You could do something like

$query="SELECT * FROM bl_admin ORDER BY id ASC"; to pull the results in order of IDs

 

Then to count the users you could do something like

$q = mysql_query("SELECT COUNT(id) FROM bl_admin");

$q = mysql_fetch_row($q); //http://php.net/mysql_fetch_row

echo "You have {$r[0]} registered users.";

Link to comment
https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244708
Share on other sites

ok well i guest I should try at lease just getting it handed to me isn't going to teach me anything

 

would i change

$query="SELECT * FROM bl_admin";

to

$query="SELECT * FROM table(adminid) bl_admin ORDER BY id ASC";

 

is that it and im kinda confused on the [where conditions] and [limit starting row, number of rows]...could someone explain please

Link to comment
https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244789
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.