Add / Sum page site, PHP-MySQL Course
              In the steps of this tutorial I will be using the XAMPP server  for Windows ...     Mars 2015     
       The Steps to Create the add and sum of the table row value in database
  1. The Testing Server
  2. Defining a Dreamweaver Site
  3. Create A Database
  4. index.php page File
     
  5. db.php page File
  6. Show or Preview Display the page site
 
 
Add / Sum
page site
 
 
 
 
Developed with
PHP & MySQL
 
 
 

The Testing Server        

If you wish to install a local testing server, you can download the XAMPP package for Windows http://www.apachefriends.org/en/xampp.html

Once XAMPP is a completely installed. XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl.
 
You can use the XAMPP Control Panel to start your testing server.

  1. Click Start next to both Apache and MySQL to start the services.
    Starting these services can take a few seconds. When it is complete, 'Running' will display beside each option.
 
To make your testing server start automatically when your computer starts, you can check the Svc checkbox beside both options.
If the XAMPP Control Panel is not already running, go to C:\xampp\control.exe to open the panel.

1- XAMPP Control Panel
 

With your testing server now installed and running, there are a few final steps you should take to make sure everything is configured to work perfectly.

  1. Open a web browser such as Firefox or Internet Explorer.
  2. In the Address bar, enter http://localhost.
    You should see a XAMPP splash screen with language options.
  3. Choose your preferred language.
    You should now see a confirmation window informing you that 'You have successfully installed XAMPP on your system'
 
 2- List of Files

t
he php files corresponding, stored at add-table_Sum Folder folder:
1- index.php and db.php - php files
 
Defining a Dreamweaver Site
Once a testing server is set up, either locally or using a remote hosting service, you will need to define a site for Dynamic Development in Dreamweaver
 

Step 1: Start the site definition

In Dreamweaver go to Site -> New Site.

Note: you can edit an existing site definition by going to Site -> Manage Sites. Select the site you wish to modify, then click the edit button.

 

Step 2: Enter the local Information

In the first section of the site definition, you will set the Local Information. This sets the Site Name, and local path for files in your site.

When using XAMPP in a windows system, it may be that the site root is mapped to:
C:\xampp\htdocs
so the new site folder would be created under that location: C:\xampp\htdocs\Sum_site

In this screen shot, using DW CS6 on a Windows system with XAMPP installed. you will set the Local Information. This sets the Site Name, and local path for files in your site.
Site Name:           Sum_site
local Site Folder: C:\xampp\htdocs\Sum_site

 

Step 3: Servers

The next setting is to connect to servers. In DW CS6 and above, this done by selecting the servers section:

and clicking the plus icon to define a new server connection.

at Basic tab, For the Name you can enter the same name as the Site definition, When using a local testing server-(Server Name: Sum_site), set Connect Using to "Local/Network"
 
Set the Server Folder to the same location as the local files set in the initial Site Settings.
Server Name:           Sum_site
connect using:             Local/Network
Server Folder:          C:\xampp\htdocs\Sum_site

Web URL:                http://localhost/Sum_site
 
at Advanced tab,
Click the advanced button and set the Application model to PHP / MySQL
Server Model:  PHP MySQL 
then click Save.
Once the connection is defined, there are check boxes to set the connection as a testing or remote connection, check the testing option.
and then Click Save, the Dreamweaver dialog box display:
 
Step 4: Manage Sites
you can edit an existing site definition by going to Site -> Manage Sites. Your Sites: Sum_site
then click Done
 
Create A Database
In this section, we'll look into how to create a database. A database is used to store information for your site.
Most web hosts use a control panel for managing your site, in the control panel they will have a way to create a MySQL Database. Once a database has been created, you can use phpMyAdmin to edit it.
phpMyAdmin is also available using most Local Testing server packages like XAMPP. The Start pages for those server will have a link to open phpMyAdmin.


Step 1: Create Database, Table and Insert data
in phpMyAdmin, go to the Databases tab. to create the sum-Add database that we will be using :
  in Create database input Sum-Add and click the Create button to have the database created:
go to the Structure tab. to create the sum-Add database that we will be using :
Create table Name = add,  Number of columns = 3, click Go
information about the 3 columns of add table:
1- column:  id               int(10)                Auto_increment
2- column: mark   decimal(20.2)
3- column: mark1    decimal(20.2)
go to the Inser tab. to Browse of Table "add" of Database "sum-add" and then click Go
go to the Browse tab. to browse values of columns data
 

 
index.php page File
 
Now that a site and a database are created, lets connect the 2 together.

Before creating the database connection, a new PHP file needs to be created and saved to the site

Step 1: Create a New PHP page

Go to File -> New. In the File Creation dialog, select Blank Page. From the page type section, select PHP and click the create.

 

Step 2: Save the page to your site

Go to File -> Save.
In the Save As option, enter "index.php"

In the Where section, select the folder for your site.

 
Step 3: the Site has been defined
- testing server
-
Once the site has been defined, at Dreamweaver - Dw display current Message: "This page may have dynamically-related files that can only be discovered by the server. Discover | Preferences.
 
Step 4: Create the connection to the database
1) open the database panel by going to Window -> Database.

2) In the database panel, click the plus button and select MySQL Connection

3) enter the:
connection name:        sumcon
MySQL server:          localhost
User name:                 root
Password:                                                  

Database:                   sum-add
4) Click the test button then Click OK
5) Click OK
 

Step 5: Create and Insert a table

Place your cursor in the one cell then Go to insert -> Table.
for the table settings, use 3 Rows, 3 Columns, set the width to 960 Pixles.

Click OK
 
Step 6: The Design and Code of index.php

 1- The Design of index.php
 
2- The Code of index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add and sum of the table row value in database</title>
<style type="text/css">

*{ margin:0px; padding:0px; font-family:Tahoma, Geneva, sans-serif; }
.container { width:960px; margin:0 auto; border:0px green dashed; min-height:200px; }
table { width:80%; margin:0 auto; border:0px solid #036; text-align:center; }
td { border:2px solid #003; padding:5px; }
.head { background-color:#903; color:#FFF; font-weight:bold; }
.foot { background-color:#C69; color:#003; font-weight:bolder; }
.sno { background-color:#000; color:#FFF; font-weight:500;}
.container h2 {
font-family: "Times New Roman", Times, serif;
}
.container h2 {
font-family: "Times New Roman", Times, serif;
}
.container h2 {
font-style: italic;
}
</style>
</head>

<body>

<div class="container">
<h2 align="center"> add / sum of the table row value in database using PHP </h2>
<?php
include('db.php');
$add=mysql_query('SELECT SUM(mark),SUM(mark1) from `add`');
while($row=mysql_fetch_array($add))
{
$mark=$row['SUM(mark)'];
$mark1=$row['SUM(mark1)'];
}
?>
<table>
<tr>
<td class="head" >S No</td>
<td class="head">Mark</td>
<td class="head">Mark 1</td>
</tr>

<?php
$table=mysql_query('SELECT * FROM `add`');
while($row1=mysql_fetch_array($table))
{
$number=$row1['id'];
$smark=$row1['mark'];
$smark1=$row1['mark1'];
?>
<tr>
<td class="sno"><?php echo $number ?></td>
<td class="mark"><?php echo $smark ?></td>
<td class="mark"><?php echo $smark1 ?></td>
</tr>
<?php } ?>
<tr>
<td class="foot">Total</td>
<td class="foot"><?php echo $mark ?></td>
<td class="foot"><?php echo $mark1 ?></td>
</tr>
</table>

</div>

</body>
</html>
 

 
db.php page File
db.php, Create New PHP file and Save it ...
 the Code, db.php file
<?php
//database name --> sum-add
//table name --> add
//table values --> id --> int(10)
// mark --> decimal (20,2)
// mark1 --> decimal (20,2)
$conn=mysql_connect('localhost','root','');
$db=mysql_select_db('sum-add',$conn);
?>

 

Show or Preview Display the page site

Preview the recordset page in the browser.

in Dreamweaver, select or open index.php file,
Go to File -> Preview in Browser -> IExplore or chrome, to Show the next picture.
 
 
pure software code