Jump to content

Archived

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

markmuir

Percentages

Recommended Posts

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

Share this post


Link to post
Share on other sites
Are you asking, how to work out the percentage, which can be maths,
Or are you asking how to show the percentage sign?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

×

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.