timmy2 Posted August 6, 2007 Share Posted August 6, 2007 I was wondering how I would Display the top 4 mysql database's? I was thinking of using the <a href="http://us3.php.net/switch">switch function</a> but I don't know what the variable would be Can someone help me? Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/ Share on other sites More sharing options...
trq Posted August 6, 2007 Share Posted August 6, 2007 Do you mean the top 4 records from a database table? SELECT fld FROM tbl ORDER BY fld2 DESC LIMIT 4; Where fld2 is satisfies the criteria as TOP. Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316709 Share on other sites More sharing options...
timmy2 Posted August 6, 2007 Author Share Posted August 6, 2007 but will that just show the databse's ? I would like it to show diffrent text for each database Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316714 Share on other sites More sharing options...
calabiyau Posted August 6, 2007 Share Posted August 6, 2007 http://www.desilva.biz/mysql/listdbs.html maybe this is what you're looking for? Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316720 Share on other sites More sharing options...
trq Posted August 6, 2007 Share Posted August 6, 2007 You need to be alot clearer in the explination of what you actually want. You also might want to look up the difference between a database (holds tables), a table (holds records), a record (holds fields) and a field (holds data). Once you've got them down, you may need to rephrase your question. Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316731 Share on other sites More sharing options...
timmy2 Posted August 6, 2007 Author Share Posted August 6, 2007 I don't know how to do this Basicly I want to have 20 groups of 3. Php or mysql adds all the rows in each group I define the groups from table's eg.(table1, table2, table3 would be a group) then it checks which groups has the most rows and display's the 4 groups that have the most row's and I echo something diffrent about each group hope this makes sense Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316895 Share on other sites More sharing options...
Barand Posted August 6, 2007 Share Posted August 6, 2007 hope this makes sense Afraid not. Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316905 Share on other sites More sharing options...
timmy2 Posted August 6, 2007 Author Share Posted August 6, 2007 what does not make sense? Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316919 Share on other sites More sharing options...
Barand Posted August 6, 2007 Share Posted August 6, 2007 What does? You know what your data looks like and how it's structured. We'd have to be clairvoyant to know what you are talking about. Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316923 Share on other sites More sharing options...
timmy2 Posted August 6, 2007 Author Share Posted August 6, 2007 Ok I'll try again I define 20 groups. In each group there are 3 tables php or mysql counts all the rows in one group (3 table's) each group echo's something diffrent the 4 groups that have the most row's echo the things I've defined. Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316931 Share on other sites More sharing options...
Barand Posted August 6, 2007 Share Posted August 6, 2007 Q1. Why is the data spread over 60 tables? Q2. How do you know which 3 tables belong to each of the 20 groups? Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316937 Share on other sites More sharing options...
timmy2 Posted August 6, 2007 Author Share Posted August 6, 2007 Q2. I would define it Group1 (table1, table2, table3); Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316957 Share on other sites More sharing options...
Barand Posted August 6, 2007 Share Posted August 6, 2007 this should help <?php function rowCount ($tablename) { $res = mysql_query ("SELECT COUNT(*) FROM `$tablename`"); return mysql_result($res, 0,0); } $count = rowCount('Table1'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/63549-displaying-the-top-4-mysql-databases/#findComment-316971 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.