473,401 Members | 2,139 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,401 software developers and data experts.

Calc total of dynamic field

hello, i'm trying to make a sum of the values find in " total3$id" but i'm sure how to do id....

Expand|Select|Wrap|Line Numbers
  1.                             <?php
  2.  
  3.                     $query="SELECT * from photo";
  4. $result = mysql_query($query) or die(mysql_error());
  5. $calcTotal = array();
  6.  
  7. while($row = mysql_fetch_array($result))
  8. {
  9.  
  10. $prezzoaccconvirgola=str_replace('.', ',', $row['prezzoacc']);
  11. $balance=$row['piante_pianali'];
  12. $allotment=$row['piante_pianali'];
  13. $total = $balance*$allotment;
  14. $prezzo=$row['prezzoacc'];
  15. $piante_cc=$row['piante_cc'];
  16. $total2 = $allotment*$total;
  17. $id=$row['id'];
  18. $calcTotal[$id] = $total;
  19. $calcTotal2[$id] = $total2;
  20. $calcTotal3[$id] = $total3;
  21. $calcTotal4[$id] = $total4; //stores each calculated total as array element with key of 'id'
  22. echo  "
  23.  
  24.     <input type='hidden' value='$balance' name='balance$id'>
  25.     <input type='hidden' value='$prezzo' name='prezzo$id'>
  26.     <input type='hidden' value='$piante_cc' name='piante_cc$id'>
  27.     <input type='hidden' value='$total3$id' name='total3$id'>
  28.                                         <td>".$row['prodotto']."</td>
  29.                                         <td>".$row['piante_pianali']."</td>
  30.                                         <td>".$row['piante_cc']."</td>
  31.                                         <td>".$prezzoaccconvirgola."</td>
  32.                                     <td><input type='number' name='allotment$id' size=8 onchange='total$id.value = ((allotment$id.value) * (balance$id.value)); total2$id.value = ((((allotment$id.value) * (balance$id.value) * (prezzo$id.value)) * 100 )/100); total3$id.value = (((allotment$id.value) * (balance$id.value)) / (piante_cc$id.value)) ; '></td>
  33.                                     <td><input type='number' value='$ThisTotal' name='total$id' align='right' size=8 readonly></td>
  34.                                     <td><input type='number' name='total2$id' align='right' size=8 readonly></td>
  35.                                     <td><input type='text' class='qty1' name='total3$id' align='right' size=8 readonly></td>
  36.  
  37.                                         </tr>
  38.  
  39.                                             ";
  40.  
  41.                                      }
  42.  
  43. ?>
  44.  
Feb 11 '20 #1
1 2186
rollerbladegirl
69 64KB
If I my suggest:

A little bit of basic math examples
https://www.homeandlearn.co.uk/php/php2p6.html

A little bit more than that
https://www.php.net/manual/en/functi...ber-format.php

A little bit of using PHP array_sum() Function
https://www.w3schools.com/Php/func_array_sum.asp

Calculating the sum of values in an array
https://www.php.net/manual/en/function.array-sum.php

I hope that helps.
Feb 14 '20 #2

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

Similar topics

1
by: Luis | last post by:
Hi, I am trying to create a stored procedures (SQL 7.0), to provide data in a crosstab format. (I'm using Crystal Reports 8.5, but the Crosstab capabilities are terrible, so I have to do as...
1
by: Simon Gare | last post by:
Hi I need to compare a dynamic field in an asp page to a field in another table, if there is no match then i would like to chane the row colour ( see code below). The problem Im having is...
1
by: alfrc | last post by:
Can you help me on how to create queries with dynamic field. Meaning field to be displayed may be either coming from text box value...... combo box value... etc. Example: I have a table with the...
2
by: Kamran | last post by:
Hi Can one implement dynamic field names in C++ and how ? I have been wrangling with that problem for a while now and I can't come up with a solution. The worst of the matter is that I am a...
8
by: machoq | last post by:
Hi folks, I have a javascript object called record and i want to pass the field name dynamically. Something like print(record.$field) It always gives me null, what can i do so that it prints...
3
by: DD77 | last post by:
i need to query an xml field, but the node name i am looking for is not constant and needs to be taken out of join result. i was trying to do something like this but it does not work: select...
4
by: Hoi Wong | last post by:
In new versions of MATLAB, I can do dynamic field like userdata.('username').electrocardiogram = 4, where 'username' can be replaced by any string variable. This made my software design much...
1
by: IShouldHaveKnownBetter | last post by:
I'm a real newbie at this... I've got a table of invoices and have created a ms sql query giving me a total of the invoices by client across months. So my columns are Client, Month 0, Month -1,...
11
by: Jrod2541 | last post by:
Back again, I posted a question similar to this yesterday, however all the vendors had there own tables, and since I plan on this database being expandable, the design had to change. So now I...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.