Percentage Calculation In Php
i have the following calculation code that adds the $total and the $tax variables..
number_format($total+$tax,2,'.','')
how i can calculate the total and then subtract 15% of the final value.
View Complete Forum Thread with Replies
Related Forum Messages:
Percentage?
I'm trying to work out the code for percentages. I want to do this. For example. $impresstions = 1000; $click = 15; What is the percent?
View Replies !
Percentage
I have the following varibles: <? $percent = 20; $total = 200; ?> Basically $percent is the percentage, such as 20% The total is the amount, such as 200 How can I deduct in php $percent from $total, so it would remove 20% from 200? Is this easy?
View Replies !
Percentage Of Results
I have a table with various colums that I would like to display some stastisics. For example on colum is Gender. It holds either Male or Female. How can I output the percentage of each? ie... Female = 80% Male = 20%
View Replies !
Calculate The Percentage Of 250 Between 150 And 450
Say I have two numbers, for example 150 and 450....and a third number between them, say 250. I want to calculate the percentage of 250 between 150 and 450, where 150 is the 0%, and 450 is the 100%. I know there is a certain formula, but seeing math was never my favorite course, I can't just figure it out.
View Replies !
GD - Make A Percentage Bar
its first time trying to use GD and i dont really know what im doing but im trying to make a percentage bar, than once ive got that sorted out i would like to put the values of the bar over the top this is the code i tried with but all it does is display the url Code:
View Replies !
Figuring Percentage
I have a math problem for php. I have a rating system on my site that I want to display a percentage. The ratings are from 1 to 5. Say I had 4 votes and they were 2,3,4,5 how would I figure the percentage? I tried 4 votes divided by the total (in this case 14) times 100, but that's not coming out right.
View Replies !
Finding A Percentage
I've been trying to do this for a while now, and it's to the point I have to figure this out. I have a comm_rating (comment rating). values are 3=positive, 2=neutral, 1=negative. I don't want to put neutral comments since to me those don't show dissatisfaction. I am trying to take all comm_rating with 3 or 1 and fully calculate the percentage of positive feedback. Kind of like how eBay does it. I just can't figure this out. Code:
View Replies !
Return The Percentage Of Time
I have a script that runs every 15 mins, 15, 30,45, 0 .how would I calculate the amount of time left until it has to run again with the percent getting higher as it is getting closer to the 15 mins. Say its 1:20 How would I return the percentage of time from 1:20 to 1:30 etc?
View Replies !
Calculate Percentage Discount
I have a field which holds a numerical value lets say 29.99 Based on whatever the value of this number is I then want to calculate 5% of the value Do I just do $discountPrice = $totalPrice * 5% Im not sure what syntax to use to achieve this
View Replies !
Get Percentage Of Search Result
I'm not sure if this is php or mysql, but I'm trying to find a function which gets the percentage match of a mysql query. I've seen it before, but can't remember it now.. I also can't remember whether it was a php function or mysql. I'm well aware that I can figure out percentages with a bit of multiplying, dividing etc, but I'm sure there's a simple bit of code to do it for me.
View Replies !
Show Percentage Of Questions
Like let's say I had 100 questions, and you got 1 of them right, that's 10%. Or if I had 4 questions and you got one of them right, that's 25%. I know how to do simple stuff like if the answer was 'B' say "you're right". But how could I do it so it sees how many answers you got right then said "you got x% correct"?
View Replies !
Recast A Float Into A Percentage
I'm drawing a number from a field in a table. the field has a datatype of float(3,2). This field holds a representation for a percentage. Viewing the applicatios back end, a visual representation of 12.00 (indicated as a percent) is fine. But on the front end of this app, this number must be used in a calculation. There's my problem - recasting this number from a float to a percentage representation (12.00 to 0.12) for use in the calculation. I've looked at number_format in php and all over the mysql manual but can't find anything that will allow me to either re-define the table field as a regular percent (which at this point I'm willing to do) or re-cast the number in a 0.xx format when it's loaded into a variable for a calculation.
View Replies !
Convert A Decimal To Percentage ?
trying to make a shooting percentage for our team. Tried serveral variations but the one below is the best I could come up with is the number in a decimal form. .Even that is going 14 places. I would like for it to show as ??% $p_array[$playerid][pave] = ($p_array[$playerid][goals]) / ($p_array[$playerid][saves]) * 100 ;
View Replies !
Add, Subtract Percentage In A Column
I need the query to add all the numbers in a column, then subtract a percentage from it to produce a final number. I came up with this. Code: SELECT SUM(price)/100*20 FROM style WHERE collection_month_id = ག-06-a' GROUP BY collection_month_id; this gives me 20 percent of the total.
View Replies !
Replace Percentage Of Keywords In A String
I'm trying to write something that replaces a percentage of keywords in html pages with links. I have something working that will replace keywords with an array of replacement terms...and something else that turns the html pages into strings. Code:
View Replies !
AVG Calculation
how to times my AVG answer by 10, my AVG shows and answer of 5 and i want it to show 50 representing the percentage, Also how would i show this as a percentage not a normal number.
View Replies !
Calculation
I'm creating an order form whereby result is displayed in the next page. <input type="radio" name="gift" value="toy A"/> <input type="radio" name="gift" value="toy B"/> <input type="radio" name="gift" value="toy C"/> They cost $5, $10 and $15 respectively. <input type="checkbox" name="extras[]" value="Ribbon" /> <input type="checkbox" name="extras[]" value="Card" /> <input type="checkbox" name="extras[]" value="Wrapper" /> <input type="checkbox" name="extras[]" value="Box" /> Additional $1 for each of the extras checked. How can I know which toy is chosen, which extras are selected and total up the cost? I just need to display the final total cost.
View Replies !
Sql Calculation
I just started using php and mysql for the past 1 month and slowly picking things up: i got a question on DB calculation. Pls refer the table below: account number ¦ payment ----------------------------- 45621 ¦ $100.00 45621 ¦ $50.00 42000 ¦ $70.00 42000 ¦ $20.00 42000 ¦ $30.00 45656 ¦ $95.00 For the account number, notice that there is duplicate account number with different payment value. Now, how do I calculate the total value for each account ie: for 45621 = $ 150.00 and 42000 = $120.00.
View Replies !
Date Calculation In PHP
Hi! I'm trying to get a date with PHP i.e. 14 days from now in yyyy-mm-dd or any other format like print (date("Y-m-d")) + 14 days. Is there an easy way to do this??
View Replies !
Binary Calculation
I need some way of determining which bits are set in a binary number. eg. Decimal Number: 40 Binary Number: 00101000 How can I determine that the binary equivalent of 8 and 32 are set??
View Replies !
Time Calculation With Php
users of my web site enter time and distance of a run the did into a http-form. the data will be processed by a php-script and stored in an mysql-database. what i want to do is to calculate from the data what time they needed for a 1k-run -> i.e.: if one runs 12k in one hour it will be 5 minutes for 1k. the problem is, the data from the textfield of the form comes in as a string and hence i just can't divide the data ride away. time input should look like: 1:00:00 distance input should look like: 12 and output should look like: 0:05:00 any ideas?
View Replies !
PHP Math Calculation
I am trying to perform a simple calculation from variables passed from a form. The code is as follows: <?php echo "Bonus for the year: <b>"; $x = (($awage * $nibt) + ($awage * $ratio)); $x = number_format($x, 2); print $x; echo "</b><p>"; $xtmp = ($x + $qtr); print $xtmp;?> The calculation multiplies two different values (based on values from the previous page), and then sets it equal to $x. The first calculation prints fine, but when I try to add it to $qtr (also passed via radio button from previous page), it doesn't calculate correctly. I found that if I hard-code the values for $x and $qtr after I print $x, then it will calculate correctly. I am thinking that I am using the variables incorrectly somewhere.
View Replies !
Leave Calculation
for example, for the first 2 years, he does not has bonus leave, on the third year onwards, he has 1 day increase. by default, he has 18 days leave, on the third year, he can carry forward the 10 days from the previous year, now, he has 28 days leave plus 1 day bonus leave = 29 days. same with the fourth year, he can carry forward 10 days, so, he has 39 days leave plus 1 day bonus leave = 40 days. if he apply 2 days leave in the first 2 years, the balance is 16 days. on the third year, he only can carry forward 10 days only, not 16 days. if he apply 12 days leave in the first 2 years, the balance is 6 days. on the third year, he only can carry forward 6 days only, not 10 days. this is the problem that u don't know how to fix, can you teach me?
View Replies !
Time Calculation
does anyone know how to calculate time difference between 2 periods of time(say 12:00 am and 1:00am) ?? i have been trying to come up with an algorithm but bugs keep crawling in.
View Replies !
Date Calculation
I would like to make a selection from the database in the following manner ie which is created in the last 1 week or last 2 weeks. There is one field named created_date in the database and the date is in the format yyyy-mm-dd. I have seen date calculations based on month and year but didn't see one on a week basis.
View Replies !
Days Calculation
i can't seem to get this what im trying to do is work out the elapsed time in DAYS from 2 dates code is: $time_now = time(); $d2 = date('Y-m-d H:i:s', $time_now); $d1 = date('Y-m-d H:i:s', strtotime($ng_date)); $days = ceil(($d1 - $d2) / (60 * 60 * 24)); when echoing out it produces: 2007-06-02 16:53:24 2007-08-27 18:00:51 which is right, but $days echoes out as 0.
View Replies !
Add Trailing Zero To Calculation
I am pulling a couple of numbers from a database (productcost and productprice). I am trying to subtract the cost from the price to calculate the profit of the item. I have this part working with no problem. My problem lies when the final number has a trailing zero it will drop that number (i.e. 1.2 as opposed to 1.20) Here is what I am using: $profit = $row_viewcoils['ProductPrice'] - $row_viewcoils['ProductCost']; echo $profit;
View Replies !
Calculation Form
I need to build a calculation form.. basically they click a couple radio buttons from features they want and then the user enter's in the number of words of the document and then they hit "calculate" button and it gives them an estimate for a quote. Need a little help with the structure of the form, anyone shed some light?
View Replies !
Calculation In A Query?
Is it possible to do something like this: UPDATE `Members` SET `hungerlevel` = (hungerlevel - 1) Im trying to run a query that updates all users in my member table and it takes 1 off their hungerlevel. I could do a while loop i suppose... i was just wondering if there was a way to do it this way.
View Replies !
Database Calculation
for example i rent a space for stock keeping and i can get 1% of total prices per day. I had created a database to record all in/out stock per day as: [date] [status] [quantities] [unit_price] 2007-09-16 'IN' 1000 3.50 2007-09-16 'OUT' 100 3.51 2007-09-17 'IN' 500 3.40 2007-09-18 'IN' 1000 3.35 Sorry for my dumb, i'm stuck on a database calculation above. i hope any expert can show me how to get income calculation between $date1 and $date2 through sql query?
View Replies !
PHP/HTML Calculation
I am making a little Purchase order entry form for a mysql database. I have the form and can submit everything just fine, Only thing is I can't seem to figure out how to make a calculation on various text boxes. I need to make a sum of a group of boxes, calculate taxes etc... Anyone able to point me to some sample code of a way to make arthimatic functions on the contnts of box1 and box 2 and put them in box 3. I will only be inserting box 3 into the database and that part works already.
View Replies !
ORDERING BY My Calculation
Is there any way I can ORDER BY $sum so that the smallest one is shown first, the problem is because the sum comes after the SELECT statement. This is a simplified version to my much larger problem. PHP Code: $maths = "SELECT * FROM maths"; $mathsResults = mysql_query($maths); while ($mathsRow = mysql_fetch_array ($mathsResults)){ $int1 = $mathsRow["int1"]; $int2 = $mathsRow["int2"]; $sum=$int1+$int2; echo $sum; }
View Replies !
Shipping Calculation
I've got to add another condition to my shipping calculation - right now it reads: if ($total > 81.75) {printf ("%01.2f", $total * .11);} else {echo "8.99 ";} The condition I need to add needs to accomodate International shipping - $total * .25. I have a field for '$shipcountry' - the new condition needs to identify whether the order is being shipping with USA or goes to another country... : something like.... IF $shipcountry = "USA", THEN DO USE CODE ABOVE ELSE $total * .25 It looks like a couple of IFs AND then ELSE to me...just wish I knew how to write it.
View Replies !
Array For A Calculation
I am currently using a an array to perform a calculation similar to http://www.webmasterworld.com/forum88/7085.htm. [example] $nearest_distance = array(); $findLocations = mysql_query("SELECT latitude, longitude FROM locations"); while ($loop_findLocations = mysql_fetch_array($findLocations)) { $latitude = $loop_findLocations["latitude"]; $longitude = $loop_findLocations["longitude"]; $yarddistance = distance($latitude, $longitude, $cutomerlat, $cutomerlong, "m"); $nearest_distance[] = $yarddistance; } sort($nearest_distance); print_r($nearest_distance); // print array echo '<br> Best Yard:'. $nearest_distance[0];
View Replies !
Calculation With Month...
I create some search option with drop down list box. search by month is 1 of them. I've a table named orders, suppose LabOrder_No & Log_date. dates are storing in database as yy-mm-dd but im retriving as dd-mm-yy. I will select a month name from list (jan,feb....dec & their values are 01,02...12), click submit button & display the total orders & quantity of that month. to collect total quantity, i wrote a function: Code:
View Replies !
Calculation Of Items
I was just wondering what method is best to use to calculate items from a drop down menu. I have two lots of drop down menu of which i want to send to a page to clarification before being submitted.
View Replies !
Days Ago Calculation?
<?php $month = 10; $day = 17; $year = 2006; $days = (mktime(0, 0, 0, date("m"), date("d"), date("Y")) - mktime(0, 0, 0, $month, $day, $year)) / 86400; echo $days; ?> -> Take the seconds from unixtime now, minus unixtime date, split by seconds in a day = amount of days ago Problem is, the output is: Code:
View Replies !
Calculation Problem
im working out a users age, by deducting the year they were born from this year 2007 so i'm born on 1979, todays year is 2007 2007 - 1979 leaves 28 but the code shows as -28 instead of just 28, i tried a str_replace but no joy ## Year calculation $profileyear = $yearborn - $thisyear; ## Get rid of the - sign str_replace("-"," ", $profileyear); can anyone tell me what i did wrong?
View Replies !
Create A Function To Do The Calculation
writing the following lines of code into a simple function. I'd like to be able to create a function to do the calculation, then feed the $a, $b, or $c variable into it. <?php $a = $kerryvotes/$votes; $kpercentage = $a * 100; $kpercent = round($kpercentage, 0); ?> <?php $b = $bushvotes/$votes; $bpercentage = $b * 100; $bpercent = round($bpercentage, 0); ?> <?php $c = $nadervotes/$votes; $npercentage = $c * 100; $npercent = round($npercentage, 0); ?>
View Replies !
Avg Time On-site Calculation
I am collecting the date and time of each visit to pages on a web-site into a MySQL DB. Would now like to use that info to calculate the avg time a visitor has been on the site. What is the best way to do that?
View Replies !
Date Comparison Calculation
I want build and extract data from a mysql table by date. The problem is that my table data needs to be by date range as follows. Example: key field is DATE field row 1: 02-19-96 to 02-06-97 row 2: 02-07-97 to 01-27-98 row 3: 01-28-98 to 02-15-99 and the input for the query will come from a FORM input (without range), example: Enter birthday input value could be 05-13-96 How can I query the table and select the row with the correct range.
View Replies !
Relative Link Calculation
I am implementing a semi-template system via the use of 'include()' which pull from files from in a dir in the document root. But as the depth of the files in the direcotry structure changes, you can well imagine that relative links get messued up as the include runs the script from the path from which it was called not the path from which it got the file. So basically I'd just like to know if anyone has a smart script to calculate reltative links.
View Replies !
Date Input And Calculation
I need to input the time into a form for a start time and an end time, and write it to the database. I also need to calculate the time to see the time elasped, and input that into a database, for a field of time spent.
View Replies !
OT: Franchisee Area Calculation
I've searched the web for weeks (on and off) but can't find any information about the topic. A client wants to set up a franchisee structure and track this information via a database. I've never done this and uncertain of how I would do it. Initially the client only wants state by state franchisees but I can see that this could eventually be scaled to districts/areas. To compound matters, my client is wanting this to work in any country.
View Replies !
|