Google Ads

How to Sum Column in MySQL using PHP/MySQL PHP Script


How to Sum Column in MySQL using PHP/MySQL PHP Script

In this tutorial, I’m going to show you how to sum MySQL column using PHP/MySQLi. I’ve also included in this tutorial the use of GROUP BY in mysqli query and the 2 mysqli methods which I have included in the comments. This tutorial does not include a good design but will give you idea on the topic.

 

Creating our Database

First, we’re going to create our database.
1. Open phpMyAdmin.
2. Click databases, create a database and name it as “sum”.
3. After creating a database, click the SQL and paste the below codes. See image below for detailed instruction.

 

  1. CREATE TABLE `product` (
  2. `productid` INT(11) NOT NULL AUTO_INCREMENT,
  3. `product_name` VARCHAR(30) NOT NULL,
  4. PRIMARY KEY(`productid`)
  5. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  1. CREATE TABLE `sales` (
  2. `salesid` INT(11) NOT NULL AUTO_INCREMENT,
  3. `productid` INT(11) NOT NULL,
  4. `sales_qty` DOUBLE NOT NULL,
  5. PRIMARY KEY(`salesid`)
  6. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

 

 

 


Related Post

Envato Affiliate Money Maker PHP Script Download Envato Affiliate Money MakerEnvato Affiliate Money MakerEnvato Affiliate Money Maker lets you create your own money making website. It automatically a...
CryptoKing – Live Feed Crypto Currency Scrip... CryptoKing is a Live Feed Cryptocurrency script built on Laravel and Vue Js. The Buyer can easily make money by Google Adsense and In-built subscripti...
Complete register domain and billing for cPanel/WH... Complete register domain and billing for cPanel/WHM v1.0.4Complete register domain and billing for cPanel/WHM v1.0.4Manage your site lodging and Contr...
B2Evolution v6.6.7 Stable Blog PHP Script B2Evolution v6.6.7 Stable Blog PHP Script Create a beautiful blog website using this php scrpt. b2evolution is an advanced weblog tool, i-e soft...
PHPfox v3.6 RC 1 PHP Script Download PHPfox v3.6 RC 1 PHP Script Download This is a popular PHP Script in the world. This script is like Facebook will support Web and Mobile Site, Poll...

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *