markmuir Posted September 6, 2006 Share Posted September 6, 2006 Hey,I would like to display a percentage of a query on my query results page i.e. display the table of results and then down at the bottom, a line saying "The total percentage is *%", but have no idea how to?? I am using a MySQL database. Any ideas?? Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/ Share on other sites More sharing options...
onlyican Posted September 6, 2006 Share Posted September 6, 2006 Are you asking, how to work out the percentage, which can be maths,Or are you asking how to show the percentage sign? Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87117 Share on other sites More sharing options...
markmuir Posted September 6, 2006 Author Share Posted September 6, 2006 I'm asking how to work out the percentage and display the result Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87124 Share on other sites More sharing options...
Ninjakreborn Posted September 6, 2006 Share Posted September 6, 2006 Are you talking about your own variation of pagination, if you are then I really like the idea.I don't know pagination yet, I like creating my own stuff. so I haven't came up with something yet, but I have to admit, if that's what you mean the idea is amazing, if you get something started, I will be happy to help you work it out, if I can remember htis post, I really like that idea, and would like to help you make it happen, you mean instead of display 4 pages of search results, show like 25% for each page, and adjust that basedon the search results, I love the idea, I know it's possible too. Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87126 Share on other sites More sharing options...
ronverdonk Posted September 6, 2006 Share Posted September 6, 2006 I really don't have a clue what you mean by "the total percentage". Of What? The following works out the number of entries on the current page as a percentage of the total number of entries and displays it.[code]<?php$total_entries = mysql_num_rows(........);entries_this_screen = 20;$percent = round($entries_this_screen * 100 / $total_entries);echo "This page shows $percent% of the total result";?>[/code]Ronald 8) Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87148 Share on other sites More sharing options...
markmuir Posted September 6, 2006 Author Share Posted September 6, 2006 For example, when I run a query searching for users who's internet has been filtered, I would like to display a table with the users name & address (have already done this) and at the bottom, display the total percentage of users that has their internet filtered. Does this make any more sense? Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87154 Share on other sites More sharing options...
ronverdonk Posted September 6, 2006 Share Posted September 6, 2006 I have no time to code the mysql stuff, but here is the idea:[code]queryA -> SELECT COUNT(*) FROM users;queryB -> SELECT userid FROM users WHERE filtered = 'ON'$total_filter = mysql_num_rows(queryB);$percent = round($total_filter * 100 / result_queryA);echo "This is $percent% of the total number of users";[/code]Ronald 8) Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87158 Share on other sites More sharing options...
markmuir Posted September 6, 2006 Author Share Posted September 6, 2006 It's ok guys, finally got it. Thanks ronverdonk for the code Quote Link to comment https://forums.phpfreaks.com/topic/19903-percentages/#findComment-87159 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.