avatar.alex Posted May 3, 2007 Share Posted May 3, 2007 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- username@hotmail.com 7 - username- username@hotmail.co.uk 8 -username- username@yahoo.com 9 -username- username@gmail.com 10 -username- username@yahoo.com 11 -username- username412@aol.com 12 -username- username@hotmail.com 13 -username- username@yahoo.com also I want to count the users in the database like You have XX registered users. Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/ Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 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."; Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244708 Share on other sites More sharing options...
avatar.alex Posted May 3, 2007 Author Share Posted May 3, 2007 the id is held in the adminid field is that a problem Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244714 Share on other sites More sharing options...
jchemie Posted May 3, 2007 Share Posted May 3, 2007 So make it order by admin_id and it will be in the ascending order.... Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244729 Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 SELECT fields [from tables] [where conditions] [order by (asc|desc)] [limit starting row, number of rows] Is the basic structure of a sql query.... Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244732 Share on other sites More sharing options...
avatar.alex Posted May 3, 2007 Author Share Posted May 3, 2007 lol sorry im kinda new what would that be in the code form Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244739 Share on other sites More sharing options...
avatar.alex Posted May 3, 2007 Author Share Posted May 3, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244789 Share on other sites More sharing options...
john010117 Posted May 3, 2007 Share Posted May 3, 2007 So what you're telling us is that adminid is in a different table? Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244821 Share on other sites More sharing options...
avatar.alex Posted May 3, 2007 Author Share Posted May 3, 2007 no the adminid is in the bl_admin ...Im confused now help please Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244824 Share on other sites More sharing options...
john010117 Posted May 3, 2007 Share Posted May 3, 2007 $query = "SELECT * FROM bl_admin ORDER BY adminid ASC"; I don't know if this is what you wanted.... Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244825 Share on other sites More sharing options...
avatar.alex Posted May 4, 2007 Author Share Posted May 4, 2007 OMG thank you john010117 that is wat it need Quote Link to comment https://forums.phpfreaks.com/topic/49884-count-in-order/#findComment-244967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.