Maison > php教程 > PHP源码 > 公司内部管理系统

公司内部管理系统

PHP中文网
Libérer: 2016-05-25 17:00:23
original
1858 Les gens l'ont consulté

1.计算收入或支出表的金额总和

<?php
 
//sum的function是用来记录支出/收入的金额总数。
// 现在遇到的问题是,如何将计算 收入表-支出表的差。
 include &#39;conn.php&#39;;
 
 function sum($name,$table_name){
 
    // 进行数据筛选
    $sql = "SELECT * FROM {$table_name} ";
    $query = mysql_query($sql);
    $list = array();
    $sum1 = 0;
 
    while($res = mysql_fetch_array($query))
    {
        $list[]=$res;
        $sum1 += $res[&#39;money&#39;];
    }
    //检测录入的表名,如果是payout,显示负数
    if($table_name == &#39;payout&#39;){
    echo  &#39;<h3 align = "center" >&#39;.$name.":"." - ".$sum1."</h3>";
    }
    else{
        echo  &#39;<h3 align = "center" >&#39;.$name.":".$sum1."</h3>";
    }
 
}
 // $sum2 = $sum(&#39;收入表:&#39;,&#39;income&#39;);
 // $sum1 = $sum(&#39;收入表:&#39;,&#39;payout&#39;);
?>
Copier après la connexion

2.收入列表

<?php
 
     session_start();
   error_reporting(0);
    include &#39;conn.php&#39;;
    include &#39;header.php&#39;;
  include &#39;sum.php&#39;;
    if(!$_SESSION[&#39;user&#39;]) header(&#39;location:index.php&#39;);
 
   //分页逻辑
       $length = 5;
        $pagenum=$_GET[&#39;page&#39;]?$_GET[&#39;page&#39;]:1;
        $offset = ($pagenum-1) * $length;
        $sql = "SELECT * FROM  income order by id asc limit {$offset},{$length}";
       $query = mysql_query($sql);
 
    //输出表格
    echo &#39;<table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9" align="center">
      <tr>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">项目</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">摘要</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">金额(元)</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">签订合同</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">提成</span></strong></div></td>
         <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">日期</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">负责人</span></strong></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE1">操作</span></strong></div></td>
      </tr>&#39;;
        echo "<h3 align=&#39;center&#39;>收入明细表</h3>";
    while($res = mysql_fetch_array($query))
    {
 
?>
<html>
<meta http-equiv=&#39;Content-Type&#39; content=&#39;text/html&#39; charset=&#39;UTF-8&#39; >
<head>
    <title></title>
</head>
<body>
  <form action="income_action.php" method="post">
         
        <tr>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><?php echo $res[&#39;project&#39;]; ?></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><span class="STYLE3"><?php echo $res[&#39;abs&#39;]; ?></span></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><span class="STYLE3"><?php echo $res[&#39;money&#39;]; ?></span></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center"><span class="STYLE3"><?php echo $res[&#39;whether&#39;]; ?> </span></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;commi&#39;]; ?></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;dates&#39;]; ?></div></td>                                                                       
 
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;user&#39;]; ?></div></td>
        <td height="22" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><a href="income_edit.php?id=<?php echo $res[&#39;id&#39;];?>">编辑</a>
                                          <a href="income_del.php?id=<?php echo $res[&#39;id&#39;];?>">删除</a></div></td>
      </tr>
 
         
         
 
    </form>
        </body>
</html>
 
<?php
}
echo "</table>";
//获取上一页下一页
        $prevpage = $pagenum-1;
        $nextpage = $pagenum+1;
?>
<html>
<meta http-equiv=&#39;Content-Type&#39; content=&#39;text/html&#39; charset=&#39;UTF-8&#39; >
<head>
  <title></title>
</head>
<body>
  <h3 align="center" ><a href="inlist.php?page=<?php echo $prevpage ?>">上一页</a> | <a href="inlist.php?page=<?php echo $nextpage ?>">下一页</a> </h3>
</body>
</html>
<?php
  
 // 计算总价
   
  echo $table =sum(&#39;收入表明细&#39;,&#39;income&#39;);
 
?>
Copier après la connexion

3.支出列表

<?php
 
  //读取payout表中的内容,并以表格形式显示
  session_start();
  error_reporting(0);
  include("conn.php");
  include &#39;function.php&#39;;
  include &#39;sum.php&#39;;
  if(!$_SESSION[&#39;user&#39;]) header("location:login.php");
  include("header.php");
  echo &#39;<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />&#39;;
 
  //分页逻辑
        $pagesize = 20;
        $pagenum = $_GET[&#39;page&#39;] ? $_GET[&#39;page&#39;] : 1;
        $offset = ($pagenum - 1) * $pagesize;
        $sql = "SELECT * FROM payout order by pid asc limit {$pagenum},{$pagesize} ";
        $query = mysql_query($sql);
         
 
  //表格开始
  echo &#39;<table width="80%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9" align="center">&#39;; 
  echo &#39;<tr>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">项目明细</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">摘要</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">金额</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">日期</span></strong></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center"><strong><span class="STYLE2">经手人</span></strong></div></td>
      </tr>&#39;;
     echo "<h3 align=&#39;center&#39;>支出明细表</h3>";
 
  //循环读取数据开始
  while ( $res = mysql_fetch_array($query)) {
?>
<!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>
<title>支出表填写</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 12px}
.STYLE3 {color: #707070; font-size: 12px; }
.STYLE5 {color: #707070; font-size: 14px; }
body {
    margin-top: 0px;
    margin-bottom: 0px;
}
.STYLE7 {font-size: 12}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
 
<body>
<form action="payout_action.php" method="post" >
 
  <tr>
    <td>
      <tr>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;project&#39;]; ?> </div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;abs&#39;]; ?></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;money&#39;]; ?></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"><?php echo $res[&#39;dates&#39;]; ?></div></td>
        <td height="26" bgcolor="#FFFFFF"><div align="center" class="STYLE5"> <?php echo $res[&#39;user&#39;]; ?></div></td>
      </tr>
 
<?php
}
 echo "</table>";
 
  //获取上一页下一页
        $prevpage = $pagenum-1;
     
        $nextpage = $pagenum+1;
 
 
?>
 
  <h3 align="center" ><a href="paylist.php?page=<?php echo $prevpage ?>">上一页</a> | <a href="paylist.php?page=<?php echo $nextpage ?>">下一页</a> </h3>
</form>
</body>
</html>
<?php
  
 $sql = "SELECT * from payout";
 $query = mysql_query($sql);
 
 //开始计算
   
  echo $sum = sum("收入表","payout");
 mysql_close();
 
 
?>
Copier après la connexion
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal