CALCULATING Row Values To Get A Total
My problem is,, that i have a PHP script that displays a table
the table has the following colums
firstname,surname,boots,hospital,woolworths,br,other, total
the firstname and surname are grabbed from the database when the page loads, what i want is for the user to enter values in the boxes under the colums boots,woolworths,hospital etc
then when they click submit,the page is refreshed, data submited into the database, bu them redisplayed in the table the values are calucated and each user is then given a total number of hours worked at those places.
im really stuck guys, havent a clue how to go about this.
so an example would be
F S boots Hospital woolworths other total
JOE BLOGS 0.8 0.8 0.8 0.8
HELP me 0.1 0.5 0.5 0.5
submit is pressed, data entered into the database, then page redisplayed with the total column totaled up.
F S boots Hospital woolworths other total
JOE BLOGS 0.8 0.8 0.8 0.8 3.2
HELP me 0.1 0.5 0.5 0.5 1.6
View Complete Forum Thread with Replies
Related Forum Messages:
Calculating Shopping Cart Total.
Everyone is going fine but i'd like the total. I seem to be having trouble calculating it. I mean once i total it up it's fine but then if i remove something the total doesn't reflect it. What is the best way of handling it?? and in a 2-d array how to i get a value of a specific row/column? i.e. if i have a price column how do i get values from it?
View Replies !
Calculating Against SQL Database, Returing Values
I was interested in trying to calculate against an SQL Table and return values that matched within the calculation. What i am trying to put together is a Zip Code Locator. I have a table "AREA" of Lat, Long and Zip Code numbers for the area im interested in. I also have a table "LOCATIONS" of Lat, Long and Zip code numbers for 25 different locations with data about Store Name, Address, etc. What i would like to do is have a user input thier Zip code and that would launch one query, which would pull down the Lat & Long from the table "AREA". I would like to then Query the database "LOCATIONS" and calculate the distance between them using a formula. So it would do this. User submit--->$_POST['zip'];---->Query and bring down LAT, LON from "AREA" table--->Query the LOCATIONS table, bring down all values---->calculate LAT, LON, from AREA table minus LAT, LON from the LOCATIONS table and populate to Variables the values that were LESS THAN 5 or something.
View Replies !
Total Of Values In A Single Column
I'm trying to retrieve the total of all values in a specific column. I know that I can use some version of "SELECT SUM" to gather the info, but I can't figure out how to convert it to a variable. Here's what I have so far: <?php $scoreTotQuery = "SELECT SUM(score) FROM pc_complete"; $scoreTotResult = mysql_query($scoreTotQuery); ?> I want to be able to retrieve the total of all scores that have been recorded, so that I can display the average score.
View Replies !
Getting Total Of 2 Values Seperated By Space
i have a DB and which has a field called rates. in rates i have 2 values stored by using a space in between. i.e 45 65 i just need to TOTAL the 2 values in the field, when i PHP a total i only get the 45, it does not read the space and misses the 65. i need to be able to total them both and get 110.
View Replies !
Calculating Age
Im trying to pull a date of birth from my database (mysql) and use this to calculate a users age for display on the page. At the moment i'm storing the date of birth of each user in three different INT fields in my table: Year - INT - 4 Day - INT - 2 Month - INT - 2 here is the code im trying to use to calculate the age: Code:
View Replies !
Calculating
when calculating i am trying to add to variables together like this but it not work why. $total = ($a+$b);
View Replies !
Calculating Tax
I have a the following tax table which shows tax calculations on wages. The way it works is that you find the row where your annual wage is between the lower and upper limits. Then the difference between your wage and the above column is multiplied by the rate. You then add the last column to your result.Code: Lower Upper Percent Above Also Add 0 2,650 0.0%00 2,650 10,120 10.0% 2,650 0 10,120 33,520 15.0% 10,120 747.00 33,520 77,075 25.0% 33,520 4,257.00 77,075 162,800 28.0% 77,075 15,145.75 162,800 351,650 33.0% 162,800 39,148.75 351,650 and over 35.0% 351,650 101,469.25 Note: Lower limit = last upper limit; above = last lower limit; also add = (last upper - lower)*last percent. Example: Say you earn 15,600 a year, you take: (15,600-10,120) * .15 + 747 = 1,569 how can you do this in PHP given these arrays:PHP Code: $LowerLimits = array(0,2650,10120,33520,77075,162800,351650);Â Â //must you have a 0? $Percents = array(0,.10,.15,.25,.28,.33,.35);
View Replies !
Calculating Colors
wondering if anyone has built or knows of a script out there that will calculate and output all of the websafe colors as hex values.
View Replies !
Calculating Duration
I'm trying to figure out how to calculate the duration when given 2 times. What I have is a script shown below in which you select a start time and end time from a drop down box, but would like some assistance on how to calculate the duration. An example: Start Time: 8:30 End Time: 9:30 Result: 1 Hour (60 mins) <tr> <td><b>Select Operation Start Time</b></td> <td><select name="start_time"> <option value="null">Select One</option> <? $start=mktime(8,30,0,date('m'),date('d'),date('Y')); for($i=$start;$i<=$start+32400;$i+=900) { $time=date("H:i",$i); echo "<option value=$time>$time</option>"; } ?> </select></td> </tr> <tr> <td><b>Select Operation End Time</b></td> <td><select name="end_time"> <option value="null">Select One</option> <? $start=mktime(8,30,0,date('m'),date('d'),date('Y')); for($i=$start;$i<=$start+32400;$i+=900) { $time=date("H:i",$i); echo "<option value=$time>$time</option>"; } ?> </select></td> </tr>
View Replies !
Calculating Tim - Easy For You! =)
I found out that i can calculate the dates e.g $today = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $yesterday = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $dayBeforeYesterday = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d") - 2, date("Y"))); $dayBeforeTheDayBeforeYesterday = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d") - 2, date("Y"))); and so on........ This works even if we have the 1st of August $yesterday gives me the 31st july. Can I do this with times also? e.g. Iit it now 17:06 an i want to make minus 20 min (like abopve minus 1 day) and I want the result to be 16:46. I tried the above example, wit %H%M but it does not work?
View Replies !
Calculating Distance
Does anyone know of a service or script where you can enter two addresses and get a distance between, or do so by range? I know mapquest has something, but I'm looking for something a little less expensive and basic? If anyone has any ideas, that would be great. BTW, it must work with PHP and MySQL
View Replies !
Calculating Checkboxes
I have made a form consisting of an array of seven checkboxes. I'm trying to figure out how to write a php script to calculate 1 dollar for every checkbox chosen.
View Replies !
Calculating With The COUNT
I am writing a simple banner management script with three tables: banner, impression & clickthrough. Banner has three columns: banner_id (pk), banner_name & banner_url Impressions has 4 columns: impression_id (pk), banner_id (fk), banner_timestamp & banner_domain. Clickthrough also has 4 columns: clickthrough_id (pk), banner_id (fk), clickthrough_timestamp & clickthrough_domain. Every time a banner is shown, a record is created in the impression db and whenever one is clicked, the clickthrough db is similarly added to. My problem comes when trying to use SQL to get the conversion rate for any particular banner. For each banner I need to count the total records in the impression db and then divide it by the count from the clickthrough db. But I cannot for the life of me work out how to get counts from two tables and perform a mathematical operation on them.
View Replies !
Calculating The Time
How would I estimate the time remaining to complete a loop if each run of the loop required a variable amount of time? For instance, if I run an array 5 elements in size that runs in a foreach loop where it took 30, 20, 53, 40, and 32 seconds each run of the loop, how could I output the estimated time until completion in seconds as the loop is running?
View Replies !
Calculating Birthdate By Given Age
I already have a method of calculating the age by a given birthdate, but I have no idea how to do that in reverse. Here's my method on calculating the age by given birthdate: <?php function calculate_age($month, $day, $year) { global $month, $day, $year; $time = time(); $new_date = mktime(0, 0, 0, $month, $day, $year); $age = ($new_date < 0) ? ($time + ($new_date * -1)) : $time - $new_date; $year = 60 * 60 * 24 * 365; $return_age = $age / $year; return floor($return_age); } ?> how do you reverse this process so it outputs the birthdate?
View Replies !
Error Calculating
I'm getting an error and I really don't know why. I get the values from a form page and I add all the values put, to get a subtotal. So far, so good. It adds perfectly. I then get this subtotal value and multiply it by 2.35 to give it a total. It works great as long as the subtotal is under 1000. I don't know why it doesn't work. This is the part of the code where it doesn't work as I would like it to. All this is supposed to do is give the value of dollars in a foreign coin. echo 'Dollars:$'.$totalamount."<br>";//this works $totalamount = $totalamount * 2.35; $totalamount = number_format($totalamount, 2); echo 'Reais:$'.$totalamount.'<br>'
View Replies !
Calculating Internet
I would like to calculate a viewer's internet connection speed when coming to a site. I've done a bunch of searches and came up with a few scripts that weren't that accurate when I tried them.
View Replies !
Calculating Timestamps
I have a mysql 3.23.58 server and php 4.2.2. I noticed that in mysql 3.23.58 when calculating a timestamp, lets say I am doing something like this in my sql. Code: select email from tbl_customer where date_added < current_timestamp and date_added > current_timestamp - 00000003000000; The date added field is actually a field that holds a time stamp. The zeros with the three represents three days before the current time stamp. I noticed that in mysql 3.23.58 it subtracts the days from 100 when the 2 digits in the timestamp that represent the month go to the previous month. In mysql 5 and newer the timestamp will calculate correctly.
View Replies !
Calculating Fields
This seems to be a simple request, But I could not find anything on the web of how to accomplish it. I have two drop down selection fields which I would like to be able to put a value on the "qty" field and the " level" field add together and show the result in the cost field on the output form. Code:
View Replies !
Calculating Time
I have 2 dates one is now and the other date I have output as 2007-04-18 02:05:22 2007-04-18 02:05:22 is the first date = $creationDate and $timestamp = time(); when i use $result = $timestamp - $creationDate; it out put time in 1176956379.
View Replies !
Calculating Mortgage APR
I've got this daunting task of calculating the APR of a mortgage, I've had a look at some JavaScript, and it looks very complex. This is what I have calculated, these are exmple figures Property value £250,000 Net Mortgage Advance £102,150 Total Mortgage Advance £102,150 Term 25 Years Total Amount Payable £205,960.81 Repayment type Repayment Basis of Rate Variable Rate Initial Interest Rate 6.45% Initial Rate Period 25 Years APR %.
View Replies !
Calculating My Wage
I would like to create a PHP-script where I can enter when I met at work, when I went home and how long a break I had. Then this should be multiplied with my hourly wage. For instance if I met at 10:00 am and left at 5:00 pm and had 1:00 hour break, my hourly wage would have to be multiplied with 6 hours. On monday-friday after 6:00 pm, on saturdays after 3:00 pm and on sundays I have an allowance which I would like to be added seperately. We could call them $eveall, $satall and $sunall (cause they are different). Finally I would like all this to be saved into a file and to be shown on my html-page with the script for each month from the 21th to the 20th (for instance should July be from June 21th to July 20th).
View Replies !
Calculating Free Space Available
Is there a way to tell how much space is remaining available for files? I'm working on a script that takes uploaded images and adds them to a database, but I'd like to check and make sure there's room for it first. I think there's probably going to be some type of issue with quotas, because that's how I found the problem. A user had uploaded a test version and got an error that a folder could not be created because of insufficient space remaining. And I know I could probably exec() out to df or something similar, but I would like it to work on Windows servers as well, so I'd prefer to keep it all in PHP code if possible.
View Replies !
Calculating CIDR Blocks
I have array of free IP addresses. One IP per line. Now I'm trying to share them to CIDR blocks /24 - /32. For example: if 1.1.1.0-1.1.1.255 is free, it returns array('.1.1.0/24') but let's say that 1.1.1.1 is used, then function should return array('.1.1.128/25', '.1.1.127/26', '.1.1.32/27', etc until free block doesn't fit). Here's my current code:
View Replies !
Calculating Future Dates
I have a variable ($today) that is simply $today = date("m/j/Y"); I want to get another variable for x months down the line, but using the php.net reference of the mktime and date command, my second date, as follows comes out in a large number. How can I make sure it is forwarding the date properly, and format it like mm/dd/yyyy? This is the line from php.net reference page. I need this to calculate properly, and format mm/dd/yyyy - just like my variable up top. $two_months_from_today = mktime(0,0,0,date("m")+2 ,date("d"),date("Y"));
View Replies !
Calculating A Few Numbers Via A Form...
I am trying to put up a script where users enter certain info into a form and after they enter the info in, they click submit and the script makes a certain calculation using those numbers. For instance, the form should look something like this: Name: Age: Height in inches: Weight in pounds: Shoe size: Then the script takes the 4 numbers inputted in the age, height, weight, and shoe size rows and does this calculation and shows the user the result: (Height + Weight) * Age) / Shoe Size
View Replies !
Calculating Days Between Two Dates
I need to calculate the numbers of days (only the number of days) between two days, one a variable $row['user_cp_name'] in the format MM/DD/YY, and another, the current time. I've tried a bunch of tutorials on the internet and none seem to work properly.
View Replies !
Calculating Correct Time
Lets start off by giving you my code (Well the important sections of it!): <?php /**/# Total Time /**/$query = "SELECT sum(hours) FROM flights ".$condition; /**/$result=mysql_query($query); /**/$blcktime = number_format(mysql_result($result,0)); /**/$query = "SELECT sum(minutes) FROM flights ".$condition; /**/$result=mysql_query($query); /**/$blckmins = number_format(mysql_result($result,0)); echo "$blcktime:$blckmins"; ?> Okay this part works. Like if there is an entry that has 20 hours in hours table and 50 minutes in minute table it displays 20:50, but my problem is if there are more than one record (Which there will be) if the previous was still true and another record had 1:30 the total would be 21:80 but this of course is not correct addition of time. And this is not a 24 hour clock it simply displays the time someones been in a game so it can go lke 300:56 too. Now how would I get it so if the $minutes were greater than 60 and divisible by 60 it would add the correct numbers to the hours like $hours = $hours + $times_divisible; or something like that! I am okay with if..else..elseif statements but that would take forever to write. thats why I need a looping sttatement but I havent got a clue how to write it.
View Replies !
Calculating Random Numbers?
I have an average. Everybody knows that the formula to find an average number is: x = (a + b + c + d) / 4 x being the average. Say I already have an average, like this: 95 = (a + b + c + d) / 4 How would I generate four random numbers added together, divided by four, to get an average that equals 95?
View Replies !
Calculating Page Bandwidth
I intend to use Ajax for a kiosk application, it's primary usage is to retrieve live data from my DB, it's a fairly small amount of data (5 fields, of small data size and limited to 15 rows). When I check my server logs I can see that the kiosk page has used a fair amount of bandwidth this month, this is obviously because a javascript timeout refreshes the data every 10 seconds. What I need to know is how to calculate the bandwidth of the data for every ten seconds and then I can do the math to work out usage hours * bandwidth per hour. This is probably a fairly simple task but I've never done it before.
View Replies !
Calculating Week Range
I am sure this has been asked before but it is difficult to search for. Given a date, is there a function or a already written script out there that will allow my to get the previous Monday before the date given? This is so that given the current date, I can show all events that are happening for that week. I also will want to do the same for the month. I know I could go about writing algorithms to calculate this, but I am sure this is something that has been done numerous times before. Also is there anywhere out there built an easy to plug in calendar view function that rather then my user manually entering the dates they want to select,can just select a particular date?
View Replies !
Calculating High Numbers
I try to calculate a high number: 2^100 so I make it like that: pow(2, 100); My result is 1.26765060023E+30 How can I calculate with that value. Or do I have to replace that by my own.
View Replies !
Calculating Server Load
Has anyone had experience setting up Zend Studio Server Components in college environments where 100-200 developers may be hitting the debugging engine at the same time? Want to determine if the installation and loading will crash this development platform that a whole bunch of students and classes depend on.
View Replies !
Auto Calculating Fields
What i have there is my form, i would like to assign a value to each box or menu option and when it is selected, for it to automatically update the total field. I have tried javascript, unsuccessfully using "OnChange" functions. I know it can be done via php, i have seen it on other sites.
View Replies !
Calculating Date Differences
What's a good way to calculate the number of days between two dates in the following format: 2003-07-15 2003-08-02 I've looked at the PHP date functions but I'm still a bit lost.
View Replies !
Calculating The Number Of Days
I have a bit of a problem calculating the number of days chosen for a report. This is what I wrote: $start = mktime(0, 0, 0, $month1, $day1, $year1); $end = mktime(0, 0, 0, $month2, $day2, $year2); $days = (($end - $start)/(60*60*24)) + 1; where the values for $month1, $day1 etc. are selects in a form. The starting and end dates must be different. This seems to work mostly except for some cases e.g. Jan-01-2006 to May-01-2006 which gives me "120.95833333333 days". Any idea what I am missing?
View Replies !
Calculating Date Query
I've been asked to develop a script where it displays todays news according to today's date, and then to display news items 5 days prior to todays date. Interesting problem, I think. Basically all the news items are stored in a database itemid int(11) heading varchar(255) prop_date varchar(255) content text So I need to select heading according to todays date, then another select heading 5 days prior to todays date.
View Replies !
Calculating Time Function
I have to calculate with time and dates.Im searching to find a custom or php function that allows me to do this. it has t work somthing like this. Adding Time 2007-06-14 + 2 days = 2007-06-16 2007-06-31 + 2 days = 2007-07-02 2007-06-11 + 1 month = 2007-07-11 2007-06-11 + 1 year = 2008-06-11 ect.. Telling Difference 2007-06-14 ~ 2007-06-16 = 2 Days ect.. Deducting Time (-) Same story for Time (00:00:00)
View Replies !
Date - Calculating Periods
How would I get the next 2 week period (closest to current date). Periods - 1st - 15th each month, 16th - end of month. [php] $now = time(); $currentDate = date("Y-m-d H:i:s", $now); $previous_period = ? // Y-m-d H:i:s $next_period= ? // Y-m-d H:i:s [/php] example output would be: today = 21st August 2007 Prev Period = 15th August 2007 Next Period = 1st September
View Replies !
Calculating Prices, Dollar Format?
I have some code which basically does some very simple addition and multiplication in order to get the total price. This is working fine, it's the way that it outputs it that troubles me. i.e 2.25 + 2.25 = $4.50 > but it just outputs it as $4.5 another example: 10 * 2 = $20.00 > but again it outputs it like $20 [ I need it to ouput like 20.00 but it does 20 instead. 6.5 instead of 6.50 etc. ] So say the total price is $total I was getting around it by just putting: $$total.00 but obviously with this it has to be a number like 10.00, 20.00 or 15.00 if it's 10.50 or 10.75 it doesn't work. In CF there is a 'dollar format' which can be used when outputting things like this. Is there a similar type function in PHP or an easy way around this?
View Replies !
Calculating Date Of Weekly Meeting
Just say I have a chat session on my site at the same time every week (eg - Friday 4pm EST). How can I calculate the time/date of the next meeting. Eg - if the current time is Thursday morning, it'll be the following day. If the current time is Friday afternoon, it needs to calculate the session in 7 days time (eg - that Friday's session has already ended). So is there a way I can calculate the date of the next session based on the current time/date? And how long till the next one? So my output would be "the next meeting is in 3 days, 22 hours and 12 minutes, on Friday 23 May 4pm"
View Replies !
Calculating Days From NOW From Future Datestamps
Hi All,I have datestamps of the format 11202006 (November 20th 2006) in the DB. All these datestamps are of the future. With reference to the datestamp, I need to query the database for all entries that are 90, 60, 29, 28, 27, 26, ... 02, 01 days away from NOW. So, if there are entries with datestamps 90 days from NOW, they will need to be displayed.The query will be run everyday through a CRON script. How do I create the queries? Would there be multiple SELECT queries? Eg: 90, 60, 29 .. 02, 01
View Replies !
Calculating Form Speed Process.
Each user have it's own technique with processing form (saving loading editing and so on). Let's think what we have 15 fields of different data. How much time you spend on scripting this form? To more concretely let's think what it's a hotel class!
View Replies !
|