Company internal management system
Release: 2016-07-25 08:48:20
Original
1367 people have browsed it
Simply record expenses, income, and reimbursements. The problem we encounter now is how to calculate the difference between the income table (income) and the expenditure table (payout). If you need the complete set of source code, you can directly leave your email address, or add me on QQ to send it directly. And I hope you can help me correct the wrong logic or how to strengthen it. Thank you
- //The function of sum is used to record the total amount of expenditure/income.
- // The problem now is how to calculate the difference between the income statement and the expense statement.
- include 'conn.php';
- function sum($name,$table_name){
- // Filter data
- $sql = "SELECT * FROM {$table_name} ";
- $query = mysql_query($sql) ;
- $list = array();
- $sum1 = 0;
- while($res = mysql_fetch_array($query))
- {
- $list[]=$res;
- $sum1 += $res['money' ];
- }
- //Detect the entered table name. If it is payout, display a negative number
- if($table_name == 'payout'){
- echo '
'.$name." :"." - ".$sum1."";
- }
- else{
- echo '
'.$name.":".$sum1. "";
- }
-
- }
-
-
- // $sum2 = $sum('income statement:','income');
- // $sum1 = $sum('income statement:', 'payout');
-
-
-
-
-
-
- ?>
Copy code
- session_start();
- error_reporting(0);
- include 'conn.php';
- include 'header.php';
- include 'sum.php';
- if(!$_SESSION['user']) header('location:index.php');
- //分页逻辑
- $length = 5;
- $pagenum=$_GET['page']?$_GET['page']:1;
- $offset = ($pagenum-1) * $length;
- $sql = "SELECT * FROM income order by id asc limit {$offset},{$length}";
- $query = mysql_query($sql);
- //输出表格
- echo '
-
-
项目 |
-
摘要 |
-
金额(元) |
-
签订合同 |
-
提成 |
-
日期 |
-
负责人 |
-
操作 |
-
';
- echo "
收入明细表";
- while($res = mysql_fetch_array($query))
- {
-
- ?>
-
-
-
-
-
-
|
-
|
-
|
-
|
-
|
-
|
-
-
|
-
|
-
-
-
-
-
-
-
-
- }
- echo "
";
- //获取上一页下一页
- $prevpage = $pagenum-1;
- $nextpage = $pagenum+1;
- ?>
-
-
-
-
- // 计算总价
-
- echo $table =sum('收入表明细','income');
- ?>
复制代码
- //读取payout表中的内容,并以表格形式显示
- session_start();
- error_reporting(0);
- include("conn.php");
- include 'function.php';
- include 'sum.php';
- if(!$_SESSION['user']) header("location:login.php");
- include("header.php");
- echo '';
-
- //分页逻辑
- $pagesize = 20;
- $pagenum = $_GET['page'] ? $_GET['page'] : 1;
- $offset = ($pagenum - 1) * $pagesize;
- $sql = "SELECT * FROM payout order by pid asc limit {$pagenum},{$pagesize} ";
- $query = mysql_query($sql);
-
-
- //表格开始
- echo '
';
- echo '
-
项目明细 |
-
摘要 |
-
金额 |
-
日期 |
-
经手人 |
-
';
- echo "
支出明细表";
-
- //循环读取数据开始
- while ( $res = mysql_fetch_array($query)) {
- ?>
- 支出表填写
-
-
-
-
-
-
-
|
-
|
-
|
-
|
-
|
-
-
- }
- echo "
| ";
-
- //Get the previous page and next page
- $prevpage = $pagenum-1;
-
- $nextpage = $pagenum+1;
-
-
- ?>
-
-
-
- $sql = "SELECT * from payout";
- $query = mysql_query($sql);
-
- //Start calculation
-
- echo $sum = sum("income table","payout");
- mysql_close();
- ?>
-
Copy code
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31