CREATE TABLE onecanteen (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Items_wholesale CHAR(30) NOT NULL,
Items_retail CHAR(30) NOT NULL,
Ammount_recive CHAR(30) NOT NULL,
items_quantity Char(30)NOt Null,
)
插入数据:
<?php
include_once 'dbconfig.php';
if(isset($_POST['btn-save']))
{
$wholesale = $_POST['Items_wholesale'];
$retail = $_POST['Items_retail'];
$quantity = $_POST['items_quantity'];
$recive = $_POST['Ammount_recive'];
if($crud->create($wholesale,$retail,$quantity,$recive))
{
header("Location: add-data.php?inserted");
}
else
{
header("Location: add-data.php?failure");
}
}
?>
php中的begnier
create / read / update / delete通常,数据存储在MySQL数据库中
在存储数据之后,我执行以下数学运算,如下所述,同时获取数据
<td> <?php print($row['id']); ?></td>
<td><?php print($row['Items_wholesale']); ?></td>
<td><?php print($row['Items_retail']); ?></td>
<td><?php print($row['items_quantity']); ?></td>
<td><?php print($row['Ammount_recive']); ?></td>
<td><?php echo $row['Items_retail'] * $row['items_quantity'] ?></td>
<td><?php echo $row['Items_wholesale'] * $row['items_quantity'] ?></td>
<td><?php echo ($row['Items_retail'] * $row['items_quantity'] )-($row['Items_wholesale'] * $row['items_quantity']) ?></td>
在这里,我看到了我的所有记录
<!-- showing whole record add delet record -->
<div class="clearfix"></div>
<div class="container">
<a href="add-data.php" class="btn btn-large btn-info"><i class="glyphicon glyphicon-plus"></i> Add Records</a>
</div>
<div class="clearfix"></div><br />
<div class="container">
<table id="table1" class='table table-bordered table-responsive'>
<tr>
<th >#</th>
<th >Wholesale</th>
<th >retail</th>
<th >Quantity</th>
<th >wholesale total</th>
<th >Retail total</th>
<th >profit</th>
<th >Recive ammount </th>
<th colspan="2" align="center">Actions</th>
<?php
$query = "SELECT * FROM onecanteen";
$records_per_page=3;
$newquery = $crud->paging($query,$records_per_page);
$crud->dataview($newquery);
?>
<tr>
程序正常工作从onecanteen表中获取数据 现在我想总结所有专栏hlpe我怎么能做到?
答案 0 :(得分:1)
要分别计算每列中的总数据量,您可以使用:
SELECT SUM(column_name) as sum1, SUM(column_name1) as sum2 FROM ....