Total Sum in a Column using PHP/MySQL
Submitted by alpha_luna on Thursday, August 25, 2016 - 13:33.
In this tutorial, we are going to create Total Sum in a Column using PHP/MySQL. This simple work created to teach the user on how to calculate the values of a column using the SUM function to the PHP query. If you want to create a simple system like a point of sale, you can put this simple function to your project. You can also check the live demo of this simple tutorial, so you can get an idea and you can try this out, let's start coding.
Sample Source Code
- <?php
- $result1 = mysql_query("SELECT sum(qty) FROM product") or die(mysql_error());
- while ($rows1 = mysql_fetch_array($result1)) {
- ?>
- <div class="pull-left">
- </div>
- <?php }
- ?>
- <?php
- $result = mysql_query("SELECT sum(amount) FROM product") or die(mysql_error());
- while ($rows = mysql_fetch_array($result)) {
- ?>
- <div class="pull-left">
- </div>
- <?php }
- ?>
Output
Hope that this simple yet useful tutorial that I created may help you to your future projects. If you are interested in programming, we have an example of programs that may help you even just in small ways. Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.Add new comment
- 611 views