Home > Backend Development > PHP Tutorial > Company internal management system

Company internal management system

WBOY
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
  1. //The function of sum is used to record the total amount of expenditure/income.
  2. // The problem now is how to calculate the difference between the income statement and the expense statement.
  3. include 'conn.php';
  4. function sum($name,$table_name){
  5. // Filter data
  6. $sql = "SELECT * FROM {$table_name} ";
  7. $query = mysql_query($sql) ;
  8. $list = array();
  9. $sum1 = 0;
  10. while($res = mysql_fetch_array($query))
  11. {
  12. $list[]=$res;
  13. $sum1 += $res['money' ];
  14. }
  15. //Detect the entered table name. If it is payout, display a negative number
  16. if($table_name == 'payout'){
  17. echo '

    '.$name." :"." - ".$sum1."

    ";
  18. }
  19. else{
  20. echo '

    '.$name.":".$sum1. "

    ";
  21. }
  22. }
  23. // $sum2 = $sum('income statement:','income');
  24. // $sum1 = $sum('income statement:', 'payout');
  25. ?>
Copy code
  1. session_start();
  2. error_reporting(0);
  3. include 'conn.php';
  4. include 'header.php';
  5. include 'sum.php';
  6. if(!$_SESSION['user']) header('location:index.php');
  7. //分页逻辑
  8. $length = 5;
  9. $pagenum=$_GET['page']?$_GET['page']:1;
  10. $offset = ($pagenum-1) * $length;
  11. $sql = "SELECT * FROM income order by id asc limit {$offset},{$length}";
  12. $query = mysql_query($sql);
  13. //输出表格
  14. echo '
  15. ';
  16. echo "

    收入明细表

    ";
  17. while($res = mysql_fetch_array($query))
  18. {
  19. ?>
  20. }
  21. echo "
  22. 项目
    摘要
    金额(元)
    签订合同
    提成
    日期
    负责人
    操作
    ";
  23. //获取上一页下一页
  24. $prevpage = $pagenum-1;
  25. $nextpage = $pagenum+1;
  26. ?>
  27. 上一页 | 下一页

  28. // 计算总价
  29. echo $table =sum('收入表明细','income');
  30. ?>
复制代码
  1. //读取payout表中的内容,并以表格形式显示
  2. session_start();
  3. error_reporting(0);
  4. include("conn.php");
  5. include 'function.php';
  6. include 'sum.php';
  7. if(!$_SESSION['user']) header("location:login.php");
  8. include("header.php");
  9. echo '';
  10. //分页逻辑
  11. $pagesize = 20;
  12. $pagenum = $_GET['page'] ? $_GET['page'] : 1;
  13. $offset = ($pagenum - 1) * $pagesize;
  14. $sql = "SELECT * FROM payout order by pid asc limit {$pagenum},{$pagesize} ";
  15. $query = mysql_query($sql);
  16. //表格开始
  17. echo '';
  18. echo '
  19. ';
  20. echo "

    支出明细表

    ";
  21. //循环读取数据开始
  22. while ( $res = mysql_fetch_array($query)) {
  23. ?>
  24. 支出表填写
  25. }
  26. echo "
  27. 项目明细
    摘要
    金额
    日期
    经手人
  28. ";
  29. //Get the previous page and next page
  30. $prevpage = $pagenum-1;
  31. $nextpage = $pagenum+1;
  32. ?>
  33. Previous page | Next page < ;/h3>

  34. $sql = "SELECT * from payout";
  35. $query = mysql_query($sql);
  36. //Start calculation
  37. echo $sum = sum("income table","payout");
  38. mysql_close();
  39. ?>
Copy code


Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template