Advertisement

07.03.2008 at 04:13PM PDT, ID: 23538424
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

PHP to convert ratio to percentage

Asked by cdukes in PHP and Databases, PHP Scripting Language

Tags:

Hi,
I'm trying to calculate a ratio to a percentage and just need a sanity check...

I have a database with hosts and message counts per host.
I need to solve for a percentage, i.e.

SELECT SUM(counter), count(host) as hc from logs WHERE counter>1;
+--------------+-----+
| SUM(counter) | hc  |
+--------------+-----+
|        50799 | 390 |
+--------------+-----+
1 row in set (0.00 sec)


so,  
counter = 50,799
hostcount = 390

which means that there are roughly 130 messages per host or a ratio of 1:130
I've included my code block and I *think* it's right, but need someone to verify.
If I run the code below, it returns 99% - is that right?



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
// Get the SQZ Savings by finding the hosts with more than 1 counter
        // and converting the ratio of hosts to hosts with > 1 to a percentage
        $sql = "SELECT SUM(counter), count(host) from ".DEFAULTLOGTABLE." WHERE counter>1";
        $query = perform_query($sql, $dbLink);
        $array = fetch_array($query);
        $hosts = $array[1];
        $mph = ($array[0]/$hosts);
        // subtract 100 from the total below to get the opposite effect (e.g: savings = 90% rather than 10%)
        // Calculation below is to get the percentage of hosts to messages_per_host (convert a ratio to percentage)
        $tot = (100 - (round(100/($mph * 100),2)) * 100);
        $SQZ_SAVINGS = $tot;
 
 
[+][-]07.03.2008 at 07:19PM PDT, ID: 21930649

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 07:20PM PDT, ID: 21930653

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 05:56AM PDT, ID: 21932835

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 05:57AM PDT, ID: 21932844

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, PHP Scripting Language
Tags: php
Sign Up Now!
Solution Provided By: cedlinx
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.04.2008 at 07:23AM PDT, ID: 21933291

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 04:37PM PDT, ID: 21935256

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628