Jump to content


Photo

Percentages


  • Please log in to reply
7 replies to this topic

#1 markmuir

markmuir
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 September 2006 - 02:10 PM

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??

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 06 September 2006 - 02:13 PM

Are you asking, how to work out the percentage, which can be maths,
Or are you asking how to show the percentage sign?
Tell me the problem, I will try tell you the solution

#3 markmuir

markmuir
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 September 2006 - 02:20 PM


I'm asking how to work out the percentage and display the result

#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 06 September 2006 - 02:24 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#5 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 06 September 2006 - 02:50 PM

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.

<?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";
?>

Ronald   8)
RTFM is an almost extinct art form, it should be subsidized.

#6 markmuir

markmuir
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 September 2006 - 02:54 PM


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?

#7 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 06 September 2006 - 03:01 PM

I have no time to code the mysql stuff, but here is the idea:

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";

Ronald  8)
RTFM is an almost extinct art form, it should be subsidized.

#8 markmuir

markmuir
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 06 September 2006 - 03:02 PM

It's ok guys, finally got it. Thanks ronverdonk for the code




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users