473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to calculate a percentage using php

Hello,

I am having some problems calculating a percentage of a number using php.

For example if i have a questionnaire that users answer on my site and the number of answers is tabulated to be 2662 and i want to calculate the percentage of yes answers from no how do i go about it?

P.S i also know how to get the number of yes and no but i don't know how to calculate the percentage of yes and no.


Any help would be appreciated thank you.
Thank you.
Jan 18 '12 #1

✓ answered by charles07

hi Joseph

calculating percentage is a coomon formula, there is nothing special in PHP

for e.g.

total no. of answers = 2662
correct answers = 2000

so % of total answers (2000 / 2662) * 100 = 75%

hope this helped.

2 9722
Rabbit
12,516 Expert Mod 8TB
percentage = (# of yes) / (# of responses) * 100
Jan 18 '12 #2
hi Joseph

calculating percentage is a coomon formula, there is nothing special in PHP

for e.g.

total no. of answers = 2662
correct answers = 2000

so % of total answers (2000 / 2662) * 100 = 75%

hope this helped.
Jan 20 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: charliewest | last post by:
Can someone pls point me to or recommend the easiest way to calculate someone´s age using the TimeSpan object, in .NET CF? Isn´t there a simple way to use the TimeSpan object to calculate the...
6
by: Programador | last post by:
I'm getting this error when running this program: Cannot calculate rate using the arguments provided Module Module1 Sub Main() Rate(360, -694.44444444444446, 244274.69178082192) End Sub
1
by: toluj | last post by:
Hi, pls could anyone help me with the script to calculate the percentage btwn two fields in a table.
3
by: tulikapuri | last post by:
Dear Friends, I am using the method to cal. percentage in report but no sucess it gives #Num! instead of a number. I am following the steps as given in help to calculate percentage value on a...
7
by: ngweixiong | last post by:
Hi, I have a Ms Access query which i used to calculate how many times the leadtime is a) less than 7 days b) 7-14 days c) more than 14 days With the query results, i will like to convert...
3
by: smileyangeluv | last post by:
Hi, Would like to get percentage for generated column. Any idea on how to do that?? Following SQL statement SELECT s.Selection_Desc, count(u.user_id) from tbl_system_selection s, tbl_user...
4
ollyb303
by: ollyb303 | last post by:
Hello, Trying to help a friend/colleague out with a database and we've both drawn a blank. Not even sure if this is possible. The database has a table (Table1) with a several columns: ID,...
5
by: NareshN | last post by:
Hi, I have weekly wise scheduled hours of each employee and no of days scheduled for each employee,now i need to calculate no of employees scheduled less than 24 hours,no of emp's scheduled b/w...
5
by: Vajid Idrees | last post by:
Hi, I am creating a report which needs to calculate the %change from the previous month. I have tried using a nested query which tries to take the value from the previous month and then the current...
0
by: Prashant Gadeka | last post by:
Hi, I am having following table structure and sample values: ---------------------------------------------------------- APP_ID DATE HOUR STATUS_CODE HITS ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.