omuyap
Recurring Revenue Specialist
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
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.
⚙ Live Demo
Sample Source Code
Output
⚙ Live Demo
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.
Download
⚙ Live Demo
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
class
=
"span"
><div
class
=
"alert alert-danger"
><i
class
=
"icon-credit-card icon-large"
></
i
>
Total number of Items:
- <b
style
=
"color:red; font-size:18px;"
><?php echo $rows1[
'sum(qty)'
]
; ?></
b
></
div
></
div
>
- </
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
class
=
"span"
><div
class
=
"alert alert-danger"
><i
class
=
"icon-credit-card icon-large"
></
i
>
Total Amount:
- <b
style
=
"color:red; font-size:18px;"
><?php echo $rows[
'sum(amount)'
]
; ?></
b
></
div
></
div
>
- </
div
>
- <?php }
- ?>
Output

⚙ Live Demo
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.
Download
You must upgrade your account or reply in the thread to view hidden text.